Flutter BlocObserver Track Your App States | App Debugging

preview_player
Показать описание
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
More about BlocObserver and BloC tutorial here
Рекомендации по теме
Комментарии
Автор

Really, we need to write another stack of code for debugging? Shouldn't it provide us an inspector UI to monitor states during app running?

ziranshuzhang