搜索插件、代码仓与 APP 分类

插件详情v0.0.2

biometricx

在您的 Flutter 应用中使用生物识别认证的简单方法。

Android
近 30 天下载
145
喜欢数
36
Pub 分数
150

安装插件

flutter pub add biometricx

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

BiometricX 是一个 Flutter 包,可简化在 Android 应用中集成生物识别认证(如指纹或面部识别)的过程。它提供了一个简单的 API,用于检查生物识别功能的可用性,并使用设备级生物识别安全地对用户进行身份验证。该包设计简洁易用,抽象了复杂的平台特定实现,使开发者能够以最少的代码实现安全的身份验证。该包仅支持 Android,并利用原生生物识别 API 实现可靠性能和安全性。

适合场景

  • 安全应用登录
  • 用户身份验证
  • 受保护的数据访问
  • 会话重新认证
  • 双因素认证

主要特点

  • 用于生物识别检查的简单 API
  • 仅支持 Android
  • 安全的生物识别认证
  • 自动回退处理
  • 所需设置最少

适合对象

  • 需要安全用户认证的应用程序
  • 寻求快速生物识别集成的开发者
  • 专注于Android安全的项目
  • 包含敏感数据的移动应用
  • 需要快速生物识别测试的原型

使用建议

  • 仅限 Android 平台
  • 需要设备生物识别硬件
  • 不支持 iOS
  • 依赖于 Android SDK 版本兼容性
  • 需要在清单中正确处理权限

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

BiometricX

The easy way to use biometric authentication in your Flutter app.
Supports Fingerprint, FaceID and Iris.

Demo APK.

Starting

$ flutter pub add biometricx

Configuration

Change your android MainActivity to extends FlutterFragmentActivity.

import io.flutter.embedding.android.FlutterFragmentActivity

// kotlin
class MainActivity: FlutterFragmentActivity() {
  ...
}
import io.flutter.embedding.android.FlutterFragmentActivity;

// java
class MainActivity extends FlutterFragmentActivity {
  ...
}

Usage

To check biometric type of your device.

BiometricType type = await BiometricX.type;

Here is the list of biometric types.

BiometricType.FACE
BiometricType.FINGERPRINT
BiometricType.IRIS
BiometricType.MULTIPLE
BiometricType.NONE
BiometricType.NO_HARDWARE
BiometricType.UNAVAILABLE
BiometricType.UNSUPPORTED

To check if your device can use biometric authentication.

bool isBiometricEnabled = await BiometricX.isEnabled;

To encrypt data using biometric authentication.

BiometricResult result = await BiometricX.encrypt({
  biometricKey: 'salkuadrat',
  message: 'This is a very secret message',
});

if (result.isSuccess && result.hasData) {
  // Keep this messageKey to decrypt your message.
  // This messageKey will be randomly generated by BiometricX plugin.
  String messageKey = result.data!;
} else {
  showToast(result.errorMsg, context: context);
}

If you need a persistent messageKey, you can supply it as parameter to encrypt.

BiometricResult result = await BiometricX.encrypt({
  biometricKey: 'salkuadrat',
  messageKey: 'secret_message', // use persistent messageKey
  message: 'This is a very secret message',
});

if (result.isSuccess && result.hasData) {
  // Keep this messageKey to decrypt your message.
  // This will be the same value as messageKey above ('secret_message')
  String messageKey = result.data!;
} else {
  showToast(result.errorMsg, context: context);
}

To decrypt data using biometric authentication.

// Use the same biometricKey that is used to encrypt your message.
// Use messageKey that you get from [BiometricX.encrypt].
BiometricResult result = await BiometricX.decrypt({
  biometricKey: 'salkuadrat',
  messageKey: messageKey,
});

if (result.isSuccess && result.hasData) {
  // This will contains your original message.
  String message = result.data!;
} else {
  showToast(result.errorMsg, context: context);
}

To show custom message in your biometric prompt, method encrypt and decrypt have parameters you can use to change the biometric prompt dialog.

BiometricResult result = await BiometricX.encrypt({
  biometricKey: 'salkuadrat',
  message: 'This is a very secret message',
  title: 'Biometric Encryption',
  subtitle: 'Enter biometric credentials to encrypt your message',
  description: 'Scan fingerprint or face.',
  negativeButtonText: 'USE PASSWORD',
  confirmationRequired: true,
});
BiometricResult message = await BiometricX.decrypt({
  biometricKey: 'salkuadrat',
  messageKey: messageKey,
  title: 'Biometric Decryption',
  subtitle: 'Enter biometric credentials to decrypt your message',
  description: 'Scan fingerprint or face.',
  negativeButtonText: 'USE PASSWORD',
  confirmationRequired: true,
});

Example

Example project.
Demo APK.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。