authenticate method
Requests biometric authentication using the Flutter Local Authentication plugin.
This method triggers a biometric authentication prompt, allowing the user to
authenticate using their fingerprint, face, or other biometric methods
supported by the device. If the user successfully authenticates, the method
returns true
. If authentication fails or is canceled, it throws an error.
Note: Biometric authentication must be supported on the device, and the user must have set up biometrics in their device settings for this method to work.
Returns true
if authentication succeeds.
Throws an exception if there's an issue with the authentication process.
See also:
Note: This method may not be available on all platforms or versions of Flutter. Make sure to check for platform compatibility before using it.
Implementation
Future<bool> authenticate() async {
final isAuthenticated =
await FlutterLocalAuthenticationPlatform.instance.authenticate();
if (isAuthenticated == true) {
return true;
} else {
throw Exception('Authentication failed or was canceled.');
}
}