canAuthenticate method
Checks whether biometric authentication is supported on the device.
This method queries the device's capabilities to determine whether biometric
authentication methods, such as fingerprint or face recognition, are available
and supported. It returns true
if biometric authentication is supported,
and false
otherwise.
Note: The availability of biometric authentication can vary by device and
platform, and the user must have set up biometrics in their device settings
for this method to return true
.
Returns true
if biometric authentication is supported, false
otherwise.
Example usage:
bool isBiometricSupported = await canAuthenticate();
if (isBiometricSupported) {
// Display biometric authentication option
} else {
// Provide an alternative authentication method
}
Throws an exception if there's an issue checking the device's support for biometric authentication.
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> canAuthenticate() async {
final isSupported =
await FlutterLocalAuthenticationPlatform.instance.canAuthenticate();
return isSupported == true;
}