Initial commit
This commit is contained in:
28
lib/core/helpers/bloc_observer.dart
Normal file
28
lib/core/helpers/bloc_observer.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import '../../food_delivery_client.dart';
|
||||
|
||||
class AppBlocObserver extends BlocObserver {
|
||||
@override
|
||||
void onEvent(Bloc bloc, Object? event) {
|
||||
super.onEvent(bloc, event);
|
||||
log('🟢 Event: ${bloc.runtimeType}, $event');
|
||||
}
|
||||
|
||||
@override
|
||||
void onChange(BlocBase bloc, Change change) {
|
||||
super.onChange(bloc, change);
|
||||
log('🟡 Change: ${bloc.runtimeType}, $change');
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
|
||||
log('🔴 Error in ${bloc.runtimeType}: $error');
|
||||
log(stackTrace.toString());
|
||||
super.onError(bloc, error, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
void onTransition(Bloc bloc, Transition transition) {
|
||||
super.onTransition(bloc, transition);
|
||||
log('🔵 Transition: ${bloc.runtimeType}, $transition');
|
||||
}
|
||||
}
|
||||
20
lib/core/helpers/enum_helpers.dart
Normal file
20
lib/core/helpers/enum_helpers.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
enum RequestStatus {
|
||||
initial,
|
||||
loading,
|
||||
loaded,
|
||||
error,
|
||||
warning,
|
||||
loadingMore;
|
||||
|
||||
bool isInitial() => this == RequestStatus.initial;
|
||||
|
||||
bool isLoading() => this == RequestStatus.loading;
|
||||
|
||||
bool isLoaded() => this == RequestStatus.loaded;
|
||||
|
||||
bool isError() => this == RequestStatus.error;
|
||||
|
||||
bool isWarning() => this == RequestStatus.warning;
|
||||
|
||||
bool isLoadingMore() => this == RequestStatus.loadingMore;
|
||||
}
|
||||
2
lib/core/helpers/helpers.dart
Normal file
2
lib/core/helpers/helpers.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'enum_helpers.dart';
|
||||
export 'bloc_observer.dart';
|
||||
Reference in New Issue
Block a user