validateBiometric method
Prompts the user for biometric authentication and returns success status.
Implementation
Future<bool> validateBiometric() async {
try {
// Optional: You can call isBiometricSupported() here if needed
List<BiometricType> availableBiometrics = await _auth.getAvailableBiometrics();
if (availableBiometrics.isEmpty) {
return false;
}
bool didAuthenticate = await _auth.authenticate(
localizedReason: 'Please authenticate to proceed',
options: const AuthenticationOptions(
biometricOnly: true,
stickyAuth: true,
useErrorDialogs: true,
),
);
return didAuthenticate;
} catch (e) {
debugPrint('Biometric authentication error: $e');
return false;
}
}