Dev Pattern Labs logo
Dev Pattern Labs Blog
Android & Flutter 3 min readNov 19, 2026

Flutter Biometric Authentication & Secure Storage in Android Studio

Protect mobile secrets using Flutter BiometricPrompt and Android Keystore AES-256 storage. Complete tutorial for banking-grade authentication security.

Dev Pattern Labs Author

Dev Pattern Labs

Peer-reviewed technical tutorial · Production tested

Smartphone fingerprint sensor illustrating mobile biometric authentication
Executive Summary & Key Insight

Protect mobile secrets using Flutter BiometricPrompt and Android Keystore AES-256 storage. Complete tutorial for banking-grade authentication security. This practical guide covers step-by-step setup, real-world code snippets, security hardening, and common production edge cases.

Executive Summary & Key Takeaway (AEO)
Storing sensitive tokens (JWTs, refresh credentials, encryption keys) inside standard SharedPreferences or plain files on Android exposes them to root extraction and backup vulnerabilities. A banking-grade security architecture pairs the flutter_secure_storage plugin (which generates an AES-256 GCM key stored inside the hardware-backed Android Keystore) with local_auth (Android BiometricPrompt API) to unlock credentials strictly upon physical fingerprint or facial confirmation.


The Hardware-Backed Mobile Security Architecture

[ User Action: Open Wallet / View Balance ]
                   │
                   ▼
       [ Prompt Biometric Auth ]
         (local_auth BiometricPrompt)
                   │
         ┌─────────┴─────────┐
         ▼ (Failed/Canceled) ▼ (Success: Fingerprint/Face)
    [ Lock App ]        [ Request Master Key from Android Keystore ]
                             │
                             ▼
                        [ Decrypt AES-256 Session Token ]
                             │
                             ▼
                        [ Execute Authenticated API Call ]

Step 1: Android Manifest Permissions & Configuration

Update android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.USE_BIOMETRIC"/>
    
    <application
        android:label="SecureApp"
        android:icon="@mipmap/ic_launcher">
        <!-- FragmentActivity required for Android BiometricPrompt -->
    </application>
</manifest>

Verify that your MainActivity.kt inherits from FlutterFragmentActivity:

package com.devpatternlabs.secureapp

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() {
}

Step 2: Encrypted Storage Configuration

Initialize flutter_secure_storage with Android Keystore options:

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

class SecureVaultService {
  static const _storage = FlutterSecureStorage(
    aOptions: AndroidOptions(
      encryptedSharedPreferences: true,
      keyCipherAlgorithm: KeyCipherAlgorithm.RSA_ECB_PKCS1Padding,
      storageCipherAlgorithm: StorageCipherAlgorithm.AES_GCM_NoPadding,
    ),
  );

  static Future<void> saveAuthToken(String token) async {
    await _storage.write(key: 'jwt_auth_token', value: token);
  }

  static Future<String?> getAuthToken() async {
    return await _storage.read(key: 'jwt_auth_token');
  }

  static Future<void> clearVault() async {
    await _storage.deleteAll();
  }
}

Step 3: Biometric Challenge with local_auth

Trigger the hardware biometric challenge before unlocking the stored secret:

import 'package:flutter/services.dart';
import 'package:local_auth/local_auth.dart';

class BiometricAuthManager {
  final LocalAuthentication _auth = LocalAuthentication();

  Future<bool> authenticateUser() async {
    final bool canAuthenticateWithBiometrics = await _auth.canCheckBiometrics;
    final bool canAuthenticate = canAuthenticateWithBiometrics || await _auth.isDeviceSupported();

    if (!canAuthenticate) {
      return false; // Fallback to PIN / Master Password
    }

    try {
      return await _auth.authenticate(
        localizedReason: 'Please scan your fingerprint or face to authenticate',
        options: const AuthenticationOptions(
          stickyAuth: true,
          biometricOnly: true,
        ),
      );
    } on PlatformException catch (e) {
      print('Biometric error: ${e.message}');
      return false;
    }
  }
}

Security Audit Best Practices

  • Enable encryptedSharedPreferences: true: Binds encryption keys to the Android Keystore hardware security module (HSM).
  • Prohibit Plaintext Caching: Never cache decrypted tokens in unencrypted Dart global variables or static state managers.

Mobile Security by Dev Pattern Labs

Building fintech, healthcare, or enterprise mobile apps? Dev Pattern Labs architects hardened mobile solutions with strict compliance standards. Explore our Mobile Engineering Services or book a 14-Day Delivery Sprint.

Companion Flutter Guides

Tags:#Flutter#Android Studio#Biometrics#Security#AES-256
Dev Pattern Labs Engineering Team

Written by Dev Pattern LabsCore Engineering

Dev Pattern Labs is an engineering lab and digital consultancy specializing in custom Next.js web applications, WooCommerce REST API integrations, and workflow automation for growing businesses.

Recommended Companion Articles