File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1+ // ignore_for_file: avoid_dynamic_calls
2+
13import 'dart:developer' ;
24
35import 'package:bloc/bloc.dart' ;
@@ -8,9 +10,27 @@ class AppBlocObserver extends BlocObserver {
810 @override
911 void onChange (BlocBase <dynamic > bloc, Change <dynamic > change) {
1012 super .onChange (bloc, change);
11- log (
12- 'onChange(${bloc .runtimeType }, $change .currentState -> $change .nextState)' ,
13- );
13+ final dynamic oldState = change.currentState;
14+ final dynamic newState = change.nextState;
15+
16+ var oldStateInfo = oldState.runtimeType.toString ();
17+ var newStateInfo = newState.runtimeType.toString ();
18+
19+ try {
20+ // Attempt to access a 'status' property if it exists
21+ if (oldState.status != null ) {
22+ oldStateInfo = 'status: ${oldState .status }' ;
23+ }
24+ if (newState.status != null ) {
25+ newStateInfo = 'status: ${newState .status }' ;
26+ }
27+ } catch (_) {
28+ // If 'status' property does not exist, or is null,
29+ // or if there's any other error accessing it,
30+ // fall back to runtimeType (which is already set).
31+ }
32+
33+ log ('onChange(${bloc .runtimeType }, $oldStateInfo -> $newStateInfo )' );
1434 }
1535
1636 @override
Original file line number Diff line number Diff line change @@ -447,9 +447,9 @@ Future<Widget> bootstrap(
447447 inlineAdCacheService: inlineAdCacheService,
448448 initialUser: initialUser,
449449 localAdRepository: localAdRepository,
450- navigatorKey: navigatorKey, // Pass the navigatorKey to App
451- initialRemoteConfig: initialRemoteConfig, // Pass the initialRemoteConfig
450+ navigatorKey: navigatorKey,
451+ initialRemoteConfig: initialRemoteConfig,
452452 initialRemoteConfigError:
453- initialRemoteConfigError, // Pass the initialRemoteConfigError
453+ initialRemoteConfigError,
454454 );
455455}
You can’t perform that action at this time.
0 commit comments