flutter_multi_bloc_builder 0.0.2 copy "flutter_multi_bloc_builder: ^0.0.2" to clipboard
flutter_multi_bloc_builder: ^0.0.2 copied to clipboard

MultiBlocBuilder is an implementation for building widgets that react to changes of multiple bloc states.

pub license

flutter_ multi_bloc_builder #

A Flutter package that helps implement the BLoC pattern. It is best used as an extension with the flutter_bloc package which already provides MultiBlocProvider and MultiBlocListener.

This package is built to work with bloc.

MultiBlocBuilder #

MultiBlocBuilder is a Flutter widget which requires minimum one Bloc and a builder function. MultiBlocBuilder handles building the widget in response to new states. It is best used in combination with the flutter_bloc package.

The MultiBlocBuilder requires two parameters.

  • blocs: Specify which bloc states the MultiBlocBuilder should observe for building the widget
  • builder: Anonymous function which returnes your custom widget tree that rebuilds on each state change.

How to use: #

final bloc1 = BlocProvider.of<MyBloc1>(context);
final bloc2 = BlocProvider.of<MyBloc2>(context);
final bloc3 = BlocProvider.of<MyBloc2>(context);

MultiBlocBuilder(
    blocs: [bloc1, bloc2, bloc3],
    builder: (context, states) {
        final state1 = states.get<MyBloc1State>();
        final state2 = states.get<MyBloc2State>();
        final state3 = states.get<MyBloc3State>();
        
        if (state1 is Loading || state2 is Loading || state3 is Loading) {
            return Text("Loading");
        } else {
            return Text("SHow some content");
        }
    }
);
5
likes
30
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

MultiBlocBuilder is an implementation for building widgets that react to changes of multiple bloc states.

Repository (GitHub)

License

MIT (license)

Dependencies

bloc, flutter

More

Packages that depend on flutter_multi_bloc_builder