Flutter BLoC: Are Cubits better then BLoC? Flutter BLoC: Are Cubits better then BLoC? dart dart

Flutter BLoC: Are Cubits better then BLoC?


There's a good overview of Cubit vs Bloc in the official documentation.

In short, Cubit's advantage is simplicity, while Bloc provides better traceability and advanced ReactiveX operations.

In our projects, we use both Cubit for simpler cases, and Bloc if the logic is more complicated and some "limitations" actually become useful:

  • You can emit a new state only as a reaction to an event, so the implementation is more straightforward (but more verbose as well).
  • All the events are processed one by one. Again, it makes implementation more reliable and easier to maintain.

Also, that can be a matter of personal preference, but I like Bloc for its close mapping to the FSM pattern. In most cases, the application state can be nicely represented as a state machine. It's easier to discuss the implementation even with a whiteboard, as you can just show the scheme with a number of states and events changing that state.

If you're happy with Cubit, then you probably don't need Bloc. After all, the main goal is to make the architecture easy to understand and to maintain.