Flutter Blocs: A Simple Introduction | by Sumit Ghosh | Feb, 2022

1. The best way to make Bloc obtainable to the Widget tree (UI)?

The Widget which provides this performance is the BlocProvider widget, BlocProvider makes the bloc obtainable to your entire Widget tree, which is handed within the little one parameter.

2. The best way to set off an Occasion from UI on some motion?

Now that now we have Bloc obtainable on the Widget tree we are able to entry it from anyplace, there are two methods to do this, —

context.learn<BlocA>();
BlocProvider.of<BlocA>(context)

3. However how will UI replace itself when a brand new state is Emitted?

Sure, you guessed that proper, there’s a widget for this too. It’s known as Bloc Shopper.

More Posts