resolved many context usage across async gaps warnings
also removed some unused code blocks
This commit is contained in:
31
lib/app.dart
31
lib/app.dart
@@ -82,7 +82,6 @@ class _KMobileState extends State<KMobile> {
|
|||||||
],
|
],
|
||||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||||
builder: (context, themeState) {
|
builder: (context, themeState) {
|
||||||
print('global theme state changed');
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
locale: _locale ?? const Locale('en'),
|
locale: _locale ?? const Locale('en'),
|
||||||
@@ -153,9 +152,13 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
final localAuth = LocalAuthentication();
|
final localAuth = LocalAuthentication();
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
if (!canCheck) return false;
|
if (!canCheck) return false;
|
||||||
|
String localizedReason = "";
|
||||||
|
if (mounted) {
|
||||||
|
localizedReason = AppLocalizations.of(context).authenticateToAccess;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
final didAuth = await localAuth.authenticate(
|
final didAuth = await localAuth.authenticate(
|
||||||
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
localizedReason: localizedReason,
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
@@ -255,11 +258,14 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
if (optIn == true) {
|
if (optIn == true) {
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
bool didAuth = false;
|
bool didAuth = false;
|
||||||
|
String authEnable = "";
|
||||||
|
if (context.mounted) {
|
||||||
|
authEnable = AppLocalizations.of(context).authenticateToEnable;
|
||||||
|
}
|
||||||
|
|
||||||
if (canCheck) {
|
if (canCheck) {
|
||||||
didAuth = await localAuth.authenticate(
|
didAuth = await localAuth.authenticate(
|
||||||
localizedReason:
|
localizedReason: authEnable,
|
||||||
AppLocalizations.of(context).authenticateToEnable,
|
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
@@ -272,11 +278,13 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => const NavigationScaffold(),
|
builder: (_) => const NavigationScaffold(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -304,17 +312,8 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
const ServiceScreen(),
|
const ServiceScreen(),
|
||||||
];
|
];
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
_pageController.jumpToPage(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print(
|
|
||||||
"--- NavigationScaffold is rebuilding with theme color: ${Theme.of(context).primaryColor}");
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvokedWithResult: (didPop, result) async {
|
onPopInvokedWithResult: (didPop, result) async {
|
||||||
@@ -418,8 +417,12 @@ class BiometricPromptScreen extends StatelessWidget {
|
|||||||
onCompleted();
|
onCompleted();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String localizedReason = "";
|
||||||
|
if (context.mounted) {
|
||||||
|
localizedReason = AppLocalizations.of(context).enableFingerprintQuick;
|
||||||
|
}
|
||||||
final didAuth = await localAuth.authenticate(
|
final didAuth = await localAuth.authenticate(
|
||||||
localizedReason: AppLocalizations.of(context).enableFingerprintQuick,
|
localizedReason: localizedReason,
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
|
Reference in New Issue
Block a user