I am getting started with Bloc in Flutter. Can anyone tell what is really "flutter_bloc" and "bloc" packages I have these questions.
The 'bloc' package contains things you will use in your Bloc layer, like the Bloc class. This isn't necessarily flutter dependent, it is just the logic architecture of your app. The 'flutter bloc' package contains elements you will use in your UI layer.
So here, we can compare the StreamBuilder in Bloc with Consumer in Provider. The difference is that StreamBuilder listens to the stream and fetches the model on every change to rebuild the widget. But Consumer listens as soon as notifyListeners() executes inside the provider class.
Bloc is a good pattern that will be suitable for almost all types of apps. It helps improve the code's quality and makes handling states in the app much more manageable. It might be challenging for someone who is just beginning to use Flutter because it uses advanced techniques like Stream and Reactive Programming.
A variation of this classical pattern has emerged from the Flutter community: BLoC. BLoC stands for Business Logic Components. The gist of BLoC is that everything in the app should be represented as a stream of events: Widgets submit events, and other widgets will respond.
The 'flutter bloc' package contains elements you will use in your UI layer. It includes widgets like BlocProvider and BlocBuilder, which are widgets and thus flutter dependent. flutter_bloc is dependent on/derived from the bloc package.
To implement bloc in a flutter app, all you need is the flutter_bloc package as it inherits/implements all the necessary classes from the bloc package.
BlocProvider is a Flutter widget which provides a bloc to its children via BlocProvider.of<T> (context). It is used as a dependency injection (DI) widget so that a single instance of a bloc can be provided to multiple widgets within a subtree.
Dynamic Form - an example of how to use the bloc and flutter_bloc packages to implement a dynamic form which pulls data from a repository. Wizard - an example of how to build a multi-step wizard using the bloc and flutter_bloc packages.
flutter_bloc is dependent on/derived from the bloc package. To implement bloc in a flutter app, all you need is the flutter_bloc package as it inherits/implements all the necessary classes from the bloc package.
The 'bloc' package contains things you will use in your Bloc layer, like the Bloc class. This isn't necessarily flutter dependent, it is just the logic architecture of your app.
The 'flutter bloc' package contains elements you will use in your UI layer. It includes widgets like BlocProvider and BlocBuilder, which are widgets and thus flutter dependent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With