diff --git a/lib/features/dashboard/screens/dashboard_screen.dart b/lib/features/dashboard/screens/dashboard_screen.dart index bea1990..c55f800 100644 --- a/lib/features/dashboard/screens/dashboard_screen.dart +++ b/lib/features/dashboard/screens/dashboard_screen.dart @@ -1,4 +1,3 @@ -// ignore_for_file: use_build_context_synchronously import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -82,8 +81,11 @@ class _DashboardScreenState extends State { // Call your AuthCubit or repository to refresh user/accounts data await context.read().refreshUserData(); } catch (e) { + if (!context.mounted) { + return; + } ScaffoldMessenger.of(context).showSnackBar( - /*const*/ SnackBar( + SnackBar( content: Text(AppLocalizations.of(context).failedToRefresh), ), ); @@ -168,6 +170,7 @@ class _DashboardScreenState extends State { onPressed: () async { final auth = LocalAuthentication(); final canCheck = await auth.canCheckBiometrics; + if (!mounted) return; bool ok = false; if (canCheck) { ok = await auth.authenticate( @@ -178,6 +181,7 @@ class _DashboardScreenState extends State { await storage.write('biometric_enabled', 'true'); } await storage.write('biometric_prompt_shown', 'true'); + if (!mounted) return; Navigator.of(context).pop(); }, child: Text(AppLocalizations.of(context).enable),