Flutter Local Authentication using Biometrics – Face ID, Touch ID, Fingerprint

flutter-local-authentication-using-biometrics-–-face-id,-touch-id,-fingerprint

As the Flutter community grows, it is also creating a variety of libraries to support the native functionality. When a user’s fingerprints, facial characteristics, or voice are used to authenticate their identification, this is referred to as biometric authentication. Let’s see how you can implement Local Authentication for Biometrics in Flutter.

image

Almost every phone on the market today has some kind of biometric authentication. We no longer need to type in a password since we can just press our fingerprints to verify our identity. Fingerprint Authentication in Flutter Apps is the topic of this essay.

Import local_auth Package

First off, We include local_auth package into our pubspec.yaml file so we can use it in our project

dependencies:
  flutter:
    sdk: flutter
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.5
  local_auth: ^2.1.2
  local_auth_android: ^1.0.14
  local_auth_ios: ^1.0.10

How to Use local_auth

This Flutter plugin enables us to authenticate users locally, on the device, using this feature.

To check whether there is local authentication available on this device or not, call canCheckBiometrics (if you need biometrics support) and/or isDeviceSupported() (if you just need some device-level authentication):

final LocalAuthentication auth = LocalAuthentication();
final bool canAuthenticateWithBiometrics = await auth.canCheckBiometrics;
final bool canAuthenticate =
    canAuthenticateWithBiometrics || await auth.isDeviceSupported();

Don’t forget to import the package into your file like this:

import 'package:local_auth/local_auth.dart';

Currently the following biometric types are implemented:

  • BiometricType.face
  • BiometricType.fingerprint
  • BiometricType.weak
  • BiometricType.strong

Enrolled Biometrics

canCheckBiometrics indicates whether hardware support is available, not whether the device has any biometrics enrolled. To get a list of enrolled biometrics, call getAvailableBiometrics().

The types are device-specific and platform-specific, and other types may be added in the future, so when possible you should not rely on specific biometric types and only check that some biometric is enrolled:

final List availableBiometrics =
await auth.getAvailableBiometrics();

if (availableBiometrics.isNotEmpty) {
  // Some biometrics are enrolled.
}

if (availableBiometrics.contains(BiometricType.strong) ||
    availableBiometrics.contains(BiometricType.face)) {
  // Specific types of biometrics are available.
  // Use checks like this with caution!
}

Options

authenticate() method uses biometric authentication when possible, but also allows fallback to pin, pattern, or passcode.

For more advanced features, check out the original post on how to implement local authentication for biometrics in Flutter

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
expressjs:-how-to-throw-custom-errors

ExpressJS: How to throw custom errors

Next Post
react-router-version-6-tutorial-how-to-set-up-react-router@6

React Router Version 6 Tutorial How to Set up React Router@6

Related Posts

網紅程式設計師回應炒股一年虧130萬:當流量主體走進散戶敘事,虧損也成了內容

一位擁有技術背景的網紅程式設計師公開承認一年在股市虧損約130萬人民幣並回應爭議。本文拆解事件經過、散戶在高波動市場的結構性劣勢,以及科技自媒體與投資敘事的邊界。 Techroomage 編輯部 · 2026年7月1日 · 閱讀約 8 分鐘 一年虧掉130萬。當這個數字出現在一個以理性、技術背景為人設的網紅程式設計師身上,它不再是單純的帳面損失,而變成了一則被演算法與留言區共同咀嚼的內容事件。微博熱搜「網紅程式設計師回應炒股1年虧130萬」之所以快速發酵,在於它踩中了一個尷尬的對比:一個理論上最懂數據、最擅長建立模型的羣體,在公開市場裡依然難以免疫散戶的宿命。 TL;DR 一位在微博具有相當關注度的網紅程式設計師公開回應「炒股一年虧損約130萬人民幣」的傳聞,承認虧損屬實並對外說明。事件折射出科技自媒體人物把個人投資經歷內容化的新趨勢,也再次暴露散戶在高波動市場中的資訊劣勢與情緒管理難題。 事件經過 熱搜話題源於這位程式設計師在社羣平臺上揭露自己過去一年累計虧損約130萬人民幣的紀錄,隨後引發大量轉發與討論。當事人隨後親自下場回應,針對外界質疑做出說明。 需要強調的是,130萬這個數字來自當事人自述與微博話題傳播,並未經第三方財報或券商資料獨立核實;其部位結構(個股、ETF、是否含融資槓桿)也未有完整公開。引用時應保留這層不確定性,避免把自述數字當成可查證的財務事實。 關鍵事實(條列) 事件主角:一位在中國社羣平臺具有技術人設、被網友稱為「網紅程式設計師」的內容創作者 關鍵數字:自述一年累計虧損約130萬人民幣(來源為當事人公開發言,未經獨立核實)…
Read More