Introduction

In this article, we are talking about Fingerprint Authentication. So far, we have discussed the authentications like Google, Facebook, Phone and email/password that will need authentication at the server-side. Fingerprint Authentication is a type of local authentication with which you can include other biometric authentication also, like face and voice recognition. We are only covering Fingerprint Authentication in this article. So, tie your seat belt and let’s start :)))

I have found a plugin, named "local_auth" for local authentication and we are going to use it for Fingerprint Authentication.

Prerequisites

The fingerprint sensor in the mobile device you are testing the application on.

Steps

Step 1

Create a new Flutter project. I have created a new project named “flutter_fingerprint_auth”.

Step 2

Add a dependency for the “local_auth” plugin in the “pubspec.yaml” file which is available in the project root directory.

dependencies:

flutter:

sdk: flutter

cupertino_icons: ^0.1.2

local_auth: ^0.4.0+1

NOTEI have tried local_auth version 0.5.2+3 but it is not working; however, version 0.4.0+1 is working perfectly fine for me with Flutter packages.

Step 3

Add a permission for Android in android/app/src/main/AndroidManifest.xml.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.app">

<uses-permission android:name="android.permission.USE_FINGERPRINT"/>

<manifest>

Step 4

I have put some main functions for understanding the whole authentication process. Please read the comments in the code which explain you the process. I have also given my GitHub project directory link below.

Conclusion

Thus, we learned how to use Fingerprint Authentication in an Android device using local_auth plugin in Flutter. This article was all about fingerprint authentication in Android; you can also use this for iOS but for that, you need to add permission to iOS which is defined in the plugin's documentation. You can use this authentication when you need a very high level of security like making payments or confidential transactions.