Platform behaviour¶
How the API maps to the native APIs of each platform.
Android¶
Backed by androidx.biometric. canAuthenticate calls BiometricManager.canAuthenticate and authenticate shows a BiometricPrompt, both with the same authenticators:
| Method | Allowed authenticators |
|---|---|
biometricsOnly |
BIOMETRIC_STRONG or BIOMETRIC_WEAK |
biometricsOrDeviceCredential |
BIOMETRIC_STRONG, BIOMETRIC_WEAK or DEVICE_CREDENTIAL |
deviceCredentialOnly |
DEVICE_CREDENTIAL |
deviceCredentialOnlyneeds Android 11 (API 30) or newer. Below that it is reported as unsupported.cancelAuthenticationcallsBiometricPrompt.cancelAuthentication.getBiometryTypereads the hardware features of the device (FEATURE_FINGERPRINT, andFEATURE_FACE/FEATURE_IRISon Android 10+). It returnsmultiplewhen there is more than one.
getAvailability maps the result of BiometricManager.canAuthenticate:
BiometricManager result |
AuthenticationAvailability |
|---|---|
BIOMETRIC_SUCCESS |
available |
BIOMETRIC_ERROR_NONE_ENROLLED |
notEnrolled for biometricsOnly, credentialNotSet for the other methods |
deviceCredentialOnly below API 30 |
unsupportedMethod |
| Anything else (no hardware, unavailable, security update…) | notAvailable |
authenticate maps the error of BiometricPrompt:
BiometricPrompt error |
AuthenticationErrorReason |
|---|---|
ERROR_USER_CANCELED, ERROR_NEGATIVE_BUTTON |
userCanceled |
ERROR_CANCELED |
systemCanceled |
ERROR_LOCKOUT, ERROR_LOCKOUT_PERMANENT |
lockedOut |
ERROR_NO_BIOMETRICS |
notEnrolled |
ERROR_HW_UNAVAILABLE, ERROR_HW_NOT_PRESENT, ERROR_SECURITY_UPDATE_REQUIRED |
notAvailable |
ERROR_NO_DEVICE_CREDENTIAL |
credentialNotSet |
| Anything else (timeout, vendor errors…) | failed |
- The negative (cancel) button is only shown for
biometricsOnly. Android does not allow it together with the device credential. authenticateneeds the host activity to be aFragmentActivity(for exampleFlutterFragmentActivity). With a plainFlutterActivityit fails with the codenull_pointer_exception;canAuthenticate,getAvailabilityandgetBiometryTypestill work. See platform setup.
iOS and macOS¶
Backed by LocalAuthentication. Both platforms share the same Swift code (the darwin folder of the plugin), so they behave in the same way.
| Method | canAuthenticate checks the policy |
authenticate evaluates |
|---|---|---|
biometricsOnly |
deviceOwnerAuthenticationWithBiometrics |
deviceOwnerAuthenticationWithBiometrics |
biometricsOrDeviceCredential |
deviceOwnerAuthentication |
deviceOwnerAuthentication |
deviceCredentialOnly |
deviceOwnerAuthentication |
An access control that only accepts the devicePasscode |
deviceOwnerAuthenticationcan be evaluated as long as a passcode (iOS) or password (macOS) is set.- With
biometricsOnlythe fallback button of the prompt is hidden. - Every call uses a new
LAContext, so a previous authentication is never reused, unless the Touch ID reuse duration allows it. - On macOS,
biometricsOrDeviceCredentialalso accepts an Apple Watch when the user enabled it to unlock the Mac. cancelAuthenticationinvalidates theLAContextof the authentication in progress.getBiometryTypemapsLAContext.biometryType:touchID→fingerprint,faceID→face,opticID→iris.
getAvailability and authenticate map the LAError in the same way. getAvailability reports notAvailable for the errors that do not have a matching availability.
LAError |
Reason / availability |
|---|---|
userCancel |
userCanceled |
systemCancel, appCancel |
systemCanceled |
biometryLockout |
lockedOut |
biometryNotEnrolled |
notEnrolled |
biometryNotAvailable, biometryNotPaired, biometryDisconnected |
notAvailable |
passcodeNotSet |
credentialNotSet |
Anything else (authenticationFailed, userFallback…) |
failed |
Linux¶
Backed by fprintd, so only fingerprints are available.
| Method | Behaviour |
|---|---|
biometricsOnly |
canAuthenticate runs fprintd-list $USER, authenticate runs fprintd-verify. |
biometricsOrDeviceCredential |
Unsupported. |
deviceCredentialOnly |
Unsupported. |
getAvailabilityisavailablewhenfprintd-list $USERsucceeds, andnotAvailableotherwise.getBiometryTypeisfingerprintwhenfprintd-list $USERsucceeds, andnoneotherwise.cancelAuthenticationis not supported and returnsfalse.
fprintd-verify does not show a dialog. Tell the user to touch the sensor in your own UI. When the fingerprint does not match, authenticate throws an AuthenticationException with the reason failed.
Windows¶
Backed by the Windows Runtime UserConsentVerifier API.
canAuthenticateandgetAvailabilitycheck whether Windows Hello is available and configured for the current user.authenticateshows the Windows Hello verification prompt associated with the app window.cancelAuthenticationcancels the verification in progress.getBiometryTypereturnsmultiplewhen Windows Hello is available, andnoneotherwise: Windows does not expose whether the configured Hello device is face, iris or fingerprint through this API.authenticatefails withnotAvailablewhen the app has no Flutter view hosted in a top-level window.- Windows selects the available Hello method itself. The three
AuthenticationMethodvalues are accepted, but Windows may use a PIN or another configured Hello verifier even when the method is namedbiometricsOnly.
Availability maps as follows:
| Windows Hello availability | AuthenticationAvailability |
|---|---|
Available |
available |
NotConfiguredForUser |
notEnrolled |
DeviceBusy, DeviceNotPresent, DisabledByPolicy |
notAvailable |
Verification results map to the shared AuthenticationErrorReason: Canceled → userCanceled, RetriesExhausted → lockedOut, NotConfiguredForUser → notEnrolled, unavailable-device results → notAvailable, and other unsuccessful results → failed.