authenticateWithDeviceCredentials method
Authenticates using device credentials (PIN/Pattern/Password) only This is useful when biometrics are locked out
Throws AuthenticationFailedException if device authentication fails
Implementation
Future<bool> authenticateWithDeviceCredentials() async {
try {
final authenticated = await _localAuth.authenticate(
localizedReason:
"Biometric authentication is temporarily disabled. Please enter your device PIN, pattern, or password to unlock.",
options: const AuthenticationOptions(
biometricOnly: false,
stickyAuth: true,
),
);
return authenticated;
} on PlatformException catch (e) {
debugPrint("Device Authentication CODE: ${e.code}");
debugPrint("Device Authentication MESSAGE: ${e.message}");
throw AuthenticationFailedException(
e.message ?? 'Device authentication failed',
e.code,
);
} catch (e) {
throw AuthenticationFailedException("Device authentication failed: $e");
}
}