Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone tell the difference of "flutter_bloc" and "bloc" packages in Flutter

I am getting started with Bloc in Flutter. Can anyone tell what is really "flutter_bloc" and "bloc" packages I have these questions.

  1. are they same.
  2. when/how to use this.
  • Thank you
like image 412
Abhin Krishna KA Avatar asked Aug 19 '20 07:08

Abhin Krishna KA


People also ask

What is the difference between BLoC and Flutter_bloc?

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.

What is the difference between provider and BLoC in Flutter?

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.

Should I use BLoC in Flutter?

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.

What is the use of BLoC in Flutter?

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.

What is the flutter_Bloc package?

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.

How to implement bloc in a Flutter App?

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.

What is blocprovider in flutter?

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.

What is dynamic form in flutter with example?

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.


Video Answer


2 Answers

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.

like image 123
GraSim Avatar answered Oct 20 '22 06:10

GraSim


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.

like image 28
Kris Avatar answered Oct 20 '22 05:10

Kris