CustomizableBlocObserver is a Dart package that provides a customizable observer for Flutter BLoC (Business Logic Component) architecture. It allows developers to easily debug and monitor events, state changes, transitions, and errors within their BLoC implementations.
Features
- Customizable Debugging: Enable or disable debugging for events, states, transitions, and errors.
- Detailed Logging: Logs detailed information about events, state changes, and transitions, including line numbers and stack traces.
- Error Handling: Captures and logs errors with detailed stack traces for easier debugging.
- Easy Integration: Seamlessly integrates with existing Flutter BLoC setups.
Getting started
To start using CustomizableBlocObserver, follow these steps:
-
Add Dependency: Add the package to your
pubspec.yamlfile.dependencies: flutter_bloc: ^8.0.0 customizable_bloc_observer: ^1.0.0
Usage
Can be used very easily
void onEvent(Bloc bloc, Object? event) {
super.onEvent(bloc, event);
if (isDebugEnabled && debugShowEvent) {
final stackTrace = StackTrace.current;
final frame = stackTrace.toString().split('\n')[3]; // Adjust index to capture developer's code
final lineNumber = frame.split(' ').last.replaceAll(')', '');
log('📢 Event Triggered: $event at line $lineNumber');
}
}
Additional information
This README provides a clear and concise overview of your package, its features, and how to get started
Libraries
- customblocobserver
- Support for doing something awesome.