Search code examples
flutterbloc

What is the difference between Cubit and Bloc?


I am a bit confused about the new release of Bloc: 6.0.0, adding Cubit notion, is the bloc depreciated or we can use both of them?


Solution

  • Cubit is a subset of the BLoC Pattern package that does not rely on events and instead uses methods to emit new states.

    So, we can use Cubit for simple states, and as needed we can use the Bloc.

    UPDATE : additional comparison

    There are many advantages of choosing Cubit over Bloc. The two main benefits are:

    Cubit is a subset of Bloc; so, it reduces complexity. Cubit eliminates the event classes. Cubit uses emit rather than yield to emit state. Since emit works synchronously, you can ensure that the state is updated in the next line.

    more details: bloclibrary