authenticate method
Authenticates the user using biometrics.
Returns true if authentication was successful, false otherwise.
reason is the message shown to the user during authentication.
Implementation
Future<bool> authenticate({
String reason = 'Please authenticate to continue',
bool useErrorDialogs = true,
bool stickyAuth = true,
}) async {
if (kIsWeb) {
return false;
}
try {
final localAuth = await _getLocalAuth();
if (localAuth == null) return false;
return await localAuth.authenticate(
localizedReason: reason,
options: AuthenticationOptions(
useErrorDialogs: useErrorDialogs,
stickyAuth: stickyAuth,
biometricOnly: false,
),
);
} catch (e) {
debugPrint('BiometricService: Error during authentication: $e');
return false;
}
}