checkBiometrics method
Future<void>
checkBiometrics(
)
Implementation
Future<void> checkBiometrics() async {
if (kIsWeb) {
AppUtils.showSnackBar('Biometric authentication is not supported on Web. Please use password.');
return;
}
try {
final bool canAuthenticateWithBiometrics = await auth.canCheckBiometrics;
final bool canAuthenticate = canAuthenticateWithBiometrics || await auth.isDeviceSupported();
if (canAuthenticate) {
final bool didAuthenticate = await auth.authenticate(
localizedReason: 'Please authenticate to access this restricted section',
options: const AuthenticationOptions(
biometricOnly: false,
stickyAuth: true,
),
);
if (didAuthenticate) {
isScreenUnlocked.value = true;
}
} else {
AppUtils.showSnackBar('Biometric authentication is not supported or configured on this device.');
}
} catch (e) {
print('Biometric error: $e');
}
}