How to detect specific Flutter BiometricType (touch or face ID) using local_auth 2.0.0

I'm implementing fingerprint and face recognition in my flutter app using local_auth 2.0.0. When calling getBiometrics() the docs list the following as available types:

/// Various types of biometric authentication.
/// Some platforms report specific biometric types, while others report only
/// classifications like strong and weak.
enum BiometricType {
  /// Face authentication.
  face,

  /// Fingerprint authentication.
  fingerprint,

  /// Iris authentication.
  iris,

  /// Any biometric (e.g. fingerprint, iris, or face) on the device that the
  /// platform API considers to be strong. For example, on Android this
  /// corresponds to Class 3.
  strong,

  /// Any biometric (e.g. fingerprint, iris, or face) on the device that the
  /// platform API considers to be weak. For example, on Android this
  /// corresponds to Class 2.
  weak,
}

My device (Android, Moto G7) only returns BiometricType.weak and BiometricType.strong - even though it supports fingerprint.

I want to check which types are available, and offer the user to login via either face or fingerprint ID. How can I be sure which is supported by the device in this case?

2 answers

  • answered 2022-05-04 10:33 suzan

    As per documentation, You could get all the available biometric types available for the device

    To get a list of enrolled biometrics, call getAvailableBiometrics:
    
    List<BiometricType> availableBiometrics =
        await auth.getAvailableBiometrics();
    
    
        if (availableBiometrics.contains(BiometricType.face)) {
            // Face ID.
        } else if (availableBiometrics.contains(BiometricType.fingerprint)) {
            // Touch ID.
        }
    

  • answered 2022-05-05 09:03 Nikita Linkov

    Since the local_auth version 2.0.0, getAvailableBiometrics only returns weak and strong biometric types for Android platform. Now getAvailableBiometrics on Android platform returns only enrolled biometric types available on device.

    Read more about measuring biometric unlock security: https://source.android.com/security/biometric/measure

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum