如何使用 local_auth 2.0.0 检测特定的 Flutter BiometricType(触摸或面部 ID)

and*_*eil 6 authentication flutter

我正在使用 local_auth 2.0.0 在我的 flutter 应用程序中实现指纹和面部识别。当调用 getBiometrics() 时,文档列出以下可用类型:

/// 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,
}
Run Code Online (Sandbox Code Playgroud)

我的设备(Android、Moto G7)仅返回BiometricType.weak-BiometricType.strong即使它支持指纹。

我想检查哪些类型可用,并让用户通过面部或指纹 ID 登录。在这种情况下,我如何确定设备支持哪一个?

小智 2

local_auth2.0.0版本开始,getAvailableBiometrics仅返回weakAndroidstrong平台的生物识别类型。现在getAvailableBiometrics,Android 平台仅返回设备上可用的注册生物识别类型。

了解有关测量生物识别解锁安全性的更多信息: https: //source.android.com/security/biometric/measure

  • 但虽然被录取了,却只表现出弱与强 (3认同)