Last active
February 25, 2022 13:12
-
-
Save saliouseck2009/79072c694996bc4dc8b711d33f323f8c to your computer and use it in GitHub Desktop.
BlocObserver usage on flutter_bloc v8.0.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleBlocObserver extends BlocObserver { | |
@override | |
void onEvent(Bloc bloc, Object? event) { | |
super.onEvent(bloc, event); | |
print(event); | |
} | |
@override | |
void onTransition(Bloc bloc, Transition transition) { | |
super.onTransition(bloc, transition); | |
print(transition); | |
} | |
@override | |
void onError(BlocBase bloc, Object error, StackTrace stackTrace) { | |
super.onError(bloc, error, stackTrace); | |
print(error); | |
} | |
@override | |
void onChange(BlocBase bloc, Change change) { | |
super.onChange(bloc, change); | |
print(change); | |
} | |
} | |
//in main function call the class to observe the hole bloc activity in the console. | |
BlocOverrides.runZoned(() { | |
runApp(const MyApp()); | |
}, blocObserver: SimpleBlocObserver()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment