diff --git a/lib/app.dart b/lib/app.dart index 99a2633..b36e009 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -82,7 +82,6 @@ class _KMobileState extends State { ], child: BlocBuilder( builder: (context, themeState) { - print('global theme state changed'); return MaterialApp( debugShowCheckedModeBanner: false, locale: _locale ?? const Locale('en'), @@ -153,9 +152,13 @@ class _AuthGateState extends State { final localAuth = LocalAuthentication(); final canCheck = await localAuth.canCheckBiometrics; if (!canCheck) return false; + String localizedReason = ""; + if (mounted) { + localizedReason = AppLocalizations.of(context).authenticateToAccess; + } try { final didAuth = await localAuth.authenticate( - localizedReason: AppLocalizations.of(context).authenticateToAccess, + localizedReason: localizedReason, options: const AuthenticationOptions( stickyAuth: true, biometricOnly: true, @@ -255,11 +258,14 @@ class _AuthGateState extends State { if (optIn == true) { final canCheck = await localAuth.canCheckBiometrics; bool didAuth = false; + String authEnable = ""; + if (context.mounted) { + authEnable = AppLocalizations.of(context).authenticateToEnable; + } if (canCheck) { didAuth = await localAuth.authenticate( - localizedReason: - AppLocalizations.of(context).authenticateToEnable, + localizedReason: authEnable, options: const AuthenticationOptions( stickyAuth: true, biometricOnly: true, @@ -272,11 +278,13 @@ class _AuthGateState extends State { } } - Navigator.of(context).pushReplacement( - MaterialPageRoute( - builder: (_) => const NavigationScaffold(), - ), - ); + if (context.mounted) { + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (_) => const NavigationScaffold(), + ), + ); + } }, ); } @@ -304,17 +312,8 @@ class _NavigationScaffoldState extends State { const ServiceScreen(), ]; - void _onItemTapped(int index) { - setState(() { - _selectedIndex = index; - }); - _pageController.jumpToPage(index); - } - @override Widget build(BuildContext context) { - print( - "--- NavigationScaffold is rebuilding with theme color: ${Theme.of(context).primaryColor}"); return PopScope( canPop: false, onPopInvokedWithResult: (didPop, result) async { @@ -418,8 +417,12 @@ class BiometricPromptScreen extends StatelessWidget { onCompleted(); return; } + String localizedReason = ""; + if (context.mounted) { + localizedReason = AppLocalizations.of(context).enableFingerprintQuick; + } final didAuth = await localAuth.authenticate( - localizedReason: AppLocalizations.of(context).enableFingerprintQuick, + localizedReason: localizedReason, options: const AuthenticationOptions( stickyAuth: true, biometricOnly: true,