File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -201,16 +201,22 @@ class _AppViewState extends State<_AppView> {
201201 // Subscribe to the authentication repository's authStateChanges stream.
202202 // This stream is the single source of truth for the user's auth state
203203 // and drives the entire app lifecycle by dispatching AppUserChanged events.
204- _userSubscription = context.read <AuthRepository >().authStateChanges.listen (
205- (user) => context.read <AppBloc >().add (AppUserChanged (user)),
206- );
204+ _userSubscription = context.read <AuthRepository >().authStateChanges.listen ((
205+ user,
206+ ) {
207+ if (mounted) {
208+ context.read <AppBloc >().add (AppUserChanged (user));
209+ }
210+ });
207211
208212 // Subscribe to foreground push notifications. When a message is received,
209213 // dispatch an event to the AppBloc to update the UI state (e.g., show an
210214 // indicator dot).
211- _onMessageSubscription = pushNotificationService.onMessage.listen (
212- (_) => context.read <AppBloc >().add (const AppInAppNotificationReceived ()),
213- );
215+ _onMessageSubscription = pushNotificationService.onMessage.listen ((_) {
216+ if (mounted) {
217+ context.read <AppBloc >().add (const AppInAppNotificationReceived ());
218+ }
219+ });
214220
215221 // Subscribe to notifications that are tapped and open the app.
216222 // This is the core of the deep-linking functionality.
You can’t perform that action at this time.
0 commit comments