Flutter BlocObserver Track Your App States | App Debugging
Here we will learn how to use BlocObserver of bloc pattern to debug your app states and events.
With this you may keep track of your app states and events that are triggers. BlocObserver gives you a few methods like onEvent(), onTransition() and onChange(). They all get called in the order I have written.
onEvent() gets called when an event has been added in the EventHanlder.
onTransition() gets called before updating the states and after onEvent() method.
onChange() gets called after onEvent() and onTransition() method.
All these methods get called before updating any states. onTransition and onChange both consist of currentState and nextState.
But onTransition also tells you which event could case the next state change. This is cool for debugging.
Get the code for the earlier tutorial from here
https://learnflutter.co/flutter-bloc-custom-tab-bar-load-network-data/
More about BlocObserver and BloC tutorial here
https://www.dbestech.com/tutorials/flutter-bloc-tutorial