I am new to Bloc in flutter, any one can please explain when should I use add() and when to use emit in Blocs?
I am new to Bloc in flutter, any one can please explain when should I use add() and when to use emit in Blocs?
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.
You should always use emit, flutter bloc was upgrade to extends Cubit class and Cubit uses emit. Add was old usage.
I would also suggest you to look up this official plugin before getting started to implement bloc on your project.
For more examples see this - https://github.com/felangel/bloc/tree/master/examples