/bloc_examples

Examples of the Flutter starter incrementer app with multiple BLoC pattern implementations.

Primary LanguageDart

Examples of BLoC Usage

A compilation of commented Flutter starter incrementer app examples, that uses BLoC.

Implementations

  • Local Instance: This example uses a plain local instance, which can be good enough for some situations.

    final incrementBloc = IncrementBloc();
  • Ancestor Provider as Stateful Widget: A generic bloc provider (code by Didier Boelens) can instantiate any BLoC that implements the provider. It can then be accesed like:

    IncrementBloc incrementBloc = BlocProvider.of<IncrementBloc>(context);

Acknowledgement

The examples were done thanks to the fantastic explanation from these articles: