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

Overview

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.

You might also like...
Tesla App Clone built in Kotlin, using Compose. The project was initially designed by Clinton using Flutter.

Tesla Tesla App Clone built in Kotlin, using Compose. The project was initially designed by Clinton using Flutter. We are keeping this repo as a singl

The application uses Firebase Authentication and Realtime Database services
The application uses Firebase Authentication and Realtime Database services

This is a Chik-Chika. Chick-Chicka is android app, which is based on popular social network - Twitter. The application uses Firebase Authentication and Realtime Database services.

Firebase Authentication and realtime database implementation in Android Kotlin

Androidfirebaseauthentication Firebase is Google’s mobile platform that helps you develop high-quality apps and provides hosted backend services such

A ToDo application that I used Firebase Authentication and Firestore.
A ToDo application that I used Firebase Authentication and Firestore.

ToDoApp With the To-Do Application, you can create notes to your list, update them or delete them. You can change its colors as you like and mark it e

Wiremock-testing - WireMock - A great library to mock APIs in your tests and supports Junit5
Wiremock-testing - WireMock - A great library to mock APIs in your tests and supports Junit5

WireMock Testing WireMock is a great library to mock APIs in your tests and supp

Find your ideal fitness partners according to your preferences and interact with them whenever you want! All this with no hassle, because there's FitMate! Take timed challenges updated daily, read blogs related to health, and be a part of numerous communities too! During covid times, partner with your FitMate to achieve your fitness goals at home. Projeto de Prova Semestral. Aplicativo Android com login e registro utilizando Firebase Authentication e consumo de API com Retrofit.
Projeto de Prova Semestral. Aplicativo Android com login e registro utilizando Firebase Authentication e consumo de API com Retrofit.

Ocean-Tech-Android Projeto de Prova Semestral. Aplicativo Android com login e cadastro utilizando Firebase Authentication e consumo de API com Retrofi

Android library for Tesla Authentication based on Tesla JSON API (Unofficial)

TeslaAndroidAuth Lightweight Android library for Tesla SSO Authentication based

FirebaseAuthentication - Login/Register Android Application using Firebase Authentication

FireBaseAuthentication This is a Firebase Authentication Application which will

Comments
  • BiometricX.encrypt returns Cancelled

    BiometricX.encrypt returns Cancelled

    In the example folder widgets/write_message.dart, BiometricX.encrypt returns automatically Cancelled without prompting user for permission. Unable to use the example after this step.

    This does not happen in the downloadable .apk file but only when running from source.

    image
    opened by dnaicker 0
  • Crash in Android when verification failed

    Crash in Android when verification failed

    E/AndroidRuntime( 8990): java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime( 8990): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:430) E/AndroidRuntime( 8990): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:272) E/AndroidRuntime( 8990): at com.salkuadrat.biometricx.BiometricxPlugin.failed(BiometricxPlugin.kt:222) E/AndroidRuntime( 8990): at com.salkuadrat.biometricx.BiometricxPlugin.access$failed(BiometricxPlugin.kt:22) E/AndroidRuntime( 8990): at com.salkuadrat.biometricx.BiometricxPlugin$encrypt$3.invoke(BiometricxPlugin.kt:152) E/AndroidRuntime( 8990): at com.salkuadrat.biometricx.BiometricxPlugin$encrypt$3.invoke(BiometricxPlugin.kt:115) E/AndroidRuntime( 8990): at com.salkuadrat.biometricx.BiometricHelper$authenticationCallback$1.onAuthenticationFailed(BiometricHelper.kt:205) E/AndroidRuntime( 8990): at androidx.biometric.BiometricFragment$11.run(BiometricFragment.java:955) E/AndroidRuntime( 8990): at android.os.Handler.handleCallback(Handler.java:883) E/AndroidRuntime( 8990): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime( 8990): at android.os.Looper.loop(Looper.java:237) E/AndroidRuntime( 8990): at android.app.ActivityThread.main(ActivityThread.java:8034) E/AndroidRuntime( 8990): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 8990): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/AndroidRuntime( 8990): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

    opened by maulanauls 0
  • Crash on Android when biometric verification failed

    Crash on Android when biometric verification failed

    version: biometricx 0.0.2 flutter 2.5.3 stable java.lang.IllegalStateException: Reply already submitted at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:243) at com.salkuadrat.biometricx.BiometricxPlugin.failed(BiometricxPlugin.kt:222) at com.salkuadrat.biometricx.BiometricxPlugin.access$failed(BiometricxPlugin.kt:22) at com.salkuadrat.biometricx.BiometricxPlugin$encrypt$3.invoke(BiometricxPlugin.kt:152) at com.salkuadrat.biometricx.BiometricxPlugin$encrypt$3.invoke(BiometricxPlugin.kt:22) at com.salkuadrat.biometricx.BiometricHelper$authenticationCallback$1.onAuthenticationFailed(BiometricHelper.kt:205) at androidx.biometric.BiometricFragment$11.run(BiometricFragment.java:955) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:205) at android.app.ActivityThread.main(ActivityThread.java:6991) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)

    opened by danielzq 1
Owner
Salman S
Telle est la Voie
Salman S
This is an Android project allowing you to use the advanced biometric authorization features.

PLEASE NOTE: If your project has minSDK 23 and should support only basic Fingerprint Authorization on most devices - take a look first at the AndroidX

Sergej Komlach 82 Dec 30, 2022
An Android app that gives you a password generated by a given phrase with a custom algorithm, it also has password and biometric security.

An Android app that gives you a password generated by a given phrase with a custom algorithm, it also has password and biometric security.

Marcos Ariel Paccor 1 May 23, 2022
A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc)

WebDevOps A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc) Join us QQ group number: 10314

SuMuCheng 22 Jan 3, 2023
A general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and efficient way

Timer Timer is a general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and effici

Amr Saraya 3 Jul 11, 2022
Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way

Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way. What is this? Shot is a Gradle plugin and

Pedro Gómez 1k Dec 30, 2022
✨ Social network app made with Android Compose, full Kotlin, Firebase Authentication, Storage and Firestore 🚀

Your friends, for real. Share daily random moments with your friends and discover who they really are. ✨ Instant Instant is a social media actually un

Vincent Guillebaud 58 Dec 23, 2022
GitTouch - An built with Flutter open-source app for GitHub, GitLab, Bitbucket, Gitea and Gitee(码云),

GitTouch - An built with Flutter open-source app for GitHub, GitLab, Bitbucket, Gitea and Gitee(码云)

GitTouch 1.3k Jan 8, 2023
This is a Movie API app in which data is fetched online from the TMDB site using API authentication.

Movie-API This is a Movie API app in which data is fetched online from the TMDB site using API authentication. MVVM model is used for Database Managme

Atishay Jain 1 Dec 4, 2021
Authenticator Pro is a free open-source two factor authentication app for Android

Authenticator Pro Authenticator Pro is a free open-source two factor authentication app for Android. It features encrypted backups, icons, categories

jmh 1k Jan 4, 2023
A Material You Two-factor Authentication app

Mauth Mauth (pronounced Moth) is a Two-Factor Authentication app with support for TOTP and HOTP (coming soon) and compatibility with Google Authentica

Xinto 126 Jan 9, 2023