Hi, I am very new to flutter, and I've been researching the state management solution for it. And it's quite over overwhelming as there so many options.
I found the "Bloc" is quite popular, and after reading some blog posts (eg, from flutter doc , another one from doc ). I believe the above two they implement the "Bloc" pattern from scratch, actually those two also implement in slightly different ways. And I believe this library is an abstraction on top of the "Bloc" pattern? am I right?
So basically everyone does the "Bloc" a bit differently when it comes to the details of implementing this pattern? Or did I miss something? after reading these posts I am more confused.
Sorry asking this kind of question here, I know this is not a bug issue, but if you can clear my mind please that will be awesome.
Hey @Nothing-Works 馃憢
BLoC is a design pattern that was created in order to help separate business logic from presentation in dart which made it easy to reuse code across AngularDart (web) and Flutter (mobile). There is no formal definition of how to implement the pattern (at least that I know of) but this article is, in my opinion, one of the best in terms of explaining the pattern.
BLoC stands for Business Logic Component.
In short, the Business Logic needs to:
- be moved to one or several BLoC s,
- be removed as much as possible from the Presentation Layer. In other words, UI components should only worry about the UI things and not about the business,
- rely on exclusive use of Streams for both input (Sink) and output (stream),
- remain platform independent,
- remain environment independent.
As you can see, this leaves the implementation wide open to interpretation and as you've pointed out there are many variations of how to implement the pattern.
The Bloc Library (bloc, flutter_bloc, and angular_bloc) was created in order to try to simplify things for developers by eliminating the complexity of having to manually manage streams (eliminating the complexity that comes with using RxDart), and reducing the amount of boilerplate code. You can check out the why bloc section of the documentation for more details.
Hope that helps! 馃憤
@felangel thank you very much for your answer, I will have a look the article that you provided,
Most helpful comment
@felangel thank you very much for your answer, I will have a look the article that you provided,