Skip to content
pubscout

generic_bloc_provider

2.1.1, released 5 years ago by robertohuertas.com

A generic InheritedWidget-based provider for BLoC state management in Flutter.

WASM-ready
$ flutter pub add generic_bloc_provider
Source repository

What it does

Provides BLoC objects down the widget tree using InheritedWidget while helping to avoid boilerplate. It automatically manages the lifecycle of the BLoC by calling its dispose method when the provider is removed.

AI-written summary of version 2.1.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using a custom BLoC pattern requiring basic stream management and disposal
  • You want a lightweight provider mechanism without heavy third-party state libraries

Skip it when

  • You are using modern state management libraries like flutter_bloc or riverpod
  • You need complex dependency injection containers

Strengths

  • Simple API with minimal boilerplate
  • Automatic lifecycle management with BLoC disposal
  • Supports custom updateShouldNotify overrides

Weaknesses

  • Relies on a custom abstract Bloc class rather than official state management packages
  • Very basic feature set compared to modern alternatives

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      bloc: AppBloc(),
      child: MaterialApp(
        home: MainPage(),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace generic_bloc_provider.

  • flutter_bloc

    It is the official, widely-adopted package for BLoC state management with extensive tooling and community support.

  • provider

    It is the standard general-purpose dependency injection and state propagation tool in Flutter.

  • riverpod

    It offers a robust, compile-safe, and modern provider system that completely replaces InheritedWidget patterns.