Search code examples
flutterblocflutter-blocflutter-state

When to use .add() and when to use emit() in Flutter Bloc?


I am new to Bloc in flutter, any one can please explain when should I use add() and when to use emit in Blocs?


Solution

  • Use emit when you want a new state for your bloc.
    Use add when you want your bloc to handle a new event.

    See the Timer tutorial as an example.