Biometric Login with FlutterFingerprint or Face ID with PIN-password Fallback

Biometric Login with Flutter: Fingerprint or Face ID with PIN/password Fallback

Apr 18, 2025 |

17 minutes read

Biometric Login with FlutterFingerprint or Face ID with PIN-password Fallback

Unlocking Secure Conversations with Biometrics

To enhance the overall security of the application, a biometric authentication system for Android and iOS has been implemented using Flutter Dart. This allows users to access their chat data through secure methods like fingerprint and facial recognition. By relying on biometrics, only verified users are able to access private conversations, ensuring stronger privacy and robust data protection.

In addition to security, a custom-designed UI was created to offer users a smooth, intuitive experience. The interface supports responsive interactions and improves usability without compromising security. The system is built on key functionalities tailored to meet project-specific needs, including:

  • Biometric Authentication: Fingerprint and face recognition are integrated into both iOS and Android apps for secure logins.
  • Secure Access Control: Only verified users can unlock and access confidential information using biometric validation.
  • Session Management: Sessions are managed securely, with automatic locks and re-authentication prompts after inactivity.

These features collectively boost the app’s security framework while offering a frictionless and modern user experience.

Problem Learning

The client required an advanced security solution that went beyond traditional login methods. To meet these needs, the project introduced several critical implementations:

  • Seamless Biometric Integration: Enabled fingerprint and facial recognition across platforms using Flutter Dart, ensuring consistent functionality in the biometric authentication system for Android and iOS.
  • Role-Based Access Control (RBAC): Access to sensitive features was tightly controlled using biometric checks, allowing only users with specific privileges to perform critical actions.
  • Secure Session Handling: Automatic session locking was implemented after periods of inactivity, requiring users to re-authenticate using biometrics.
  • Multi-Factor Authentication (MFA): Combined biometric login with additional methods such as PIN or password for added protection.
  • Device Compatibility & Fallback Support: Provided backup options like PIN or pattern login on devices that didn’t support biometrics or when biometric scanning failed.
  • Compliance & Privacy Standards: Ensured full alignment with Apple’s Face ID guidelines and Android’s BiometricPrompt API, keeping user data private and secure.

By embedding these mechanisms, the app achieved a balance between airtight security and a seamless user interface.

Overcoming Challenges

Device Compatibility & API Limitations

A major hurdle was ensuring consistent biometric support across diverse mobile devices. Differences in biometric hardware and OS APIs required the use of fallback mechanisms (PIN or password) for unsupported scenarios.

Security & Data Privacy

All biometric data was handled using platform-specific secure storage—Apple’s Secure Enclave and Android’s Keystore—to prevent exposure to third-party applications or malicious activity.

User Onboarding & Enrollment

Users were guided through a clean and easy enrollment process that minimized failed scans due to wet fingers, poor lighting, or incorrect positioning, ensuring a more accurate authentication experience.

Session Auto-Locking

To prevent unauthorized access, the app automatically locks itself after a set period of inactivity. Biometric re-authentication is then required to continue the session securely.

Fallback Options for Biometric Failures

In conditions where biometrics fail, such as when hardware malfunctions or user conditions interfere (e.g., wet hands), users can switch to fallback methods like PINs or pattern unlocks to regain access.

Compliance with Security Guidelines

The system fully complies with GDPR, OWASP standards, and mobile security protocols to ensure lawful and responsible handling of personal data.

Our Solution

Cross-Platform Biometric Integration

Using Flutter Dart, the team successfully integrated biometric authentication systems for Android and iOS, leveraging Face ID, Touch ID, and BiometricPrompt APIs for cross-device compatibility.

Secure Storage of Biometric Data

All sensitive biometric operations are handled within Apple’s Secure Enclave and Android’s Keystore, ensuring that private information never leaves the device or gets exposed.

Simple and Guided User Experience

The biometric setup flow includes real-time prompts and fallback suggestions. This ensures users can quickly register their biometrics and access the app without frustration.

Advanced Session Management

An intelligent auto-lock mechanism secures the app after inactivity. To resume, biometric re-verification is required, ensuring both security and user convenience.

Adaptive Authentication Strategy

Fallback authentication is automatically offered if biometric access is unavailable, keeping the user experience uninterrupted while maintaining strong protection.

Regulatory Compliance & Security Assurance

The implementation strictly follows GDPR, OWASP, and other security standards to safeguard data integrity, user identity, and legal compliance throughout the system.

A) Required declaration with global variable declaration:

final LocalAuthentication auth = LocalAuthentication();
_SupportState _supportState = _SupportState.unknown;
bool? _canCheckBiometrics;
List<BiometricType>? _availableBiometrics;
String _authorized = ‘Not Authorized’;
bool _isAuthenticating = false;

B) Check the supported biometric authentication:

@overridevoid initState()
{
super.initState();
auth.isDeviceSupported().then((bool isSupported) => setState(() =>
_supportState =   isSupported ? _SupportState.supported : _SupportState.unsupported));
}
  Future<void> _checkBiometrics() async {
late bool canCheckBiometrics;
try {
canCheckBiometrics = await auth.canCheckBiometrics;
} on PlatformException catch (e) {
canCheckBiometrics = false;
print(e);
}
if (!mounted) {
Return;
}
setState(() {
_canCheckBiometrics = canCheckBiometrics;
});
}
Future<void> _getAvailableBiometrics() async {
late List<BiometricType> availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} on PlatformException catch (e) {
availableBiometrics = <BiometricType>[];
print(e);
}
if (!mounted) {
Return;
}
setState(() {
_availableBiometrics = availableBiometrics;
});
}

C) Managed the authentication and cancel flow:

Future<void> _authenticate() async {
bool authenticated = false;
try {
setState(() {
_isAuthenticating = true;
_authorized = ‘Authenticating’;
});
authenticated = await auth.authenticate(
localizedReason: ‘Let OS determine authentication method’,
options: const AuthenticationOptions(
stickyAuth: true,
),
);
setState(() {
_isAuthenticating = false;
});
} on PlatformException catch (e) {
print(e);
setState(() {
_isAuthenticating = false;
_authorized = ‘Error – ${e.message}’;
});
Return;
}
if (!mounted) {
Return;
}
setState(
() => _authorized = authenticated ? ‘Authorized’ : ‘Not Authorized’);
}
Future<void> _authenticateWithBiometrics() async {
bool authenticated = false;
try {
setState(() {
_isAuthenticating = true;
_authorized = ‘Authenticating’;
});
authenticated = await auth.authenticate(
localizedReason:
‘Scan your fingerprint (or face or whatever) to authenticate’,
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
),
);
setState(() {
_isAuthenticating = false;
_authorized = ‘Authenticating’;
});
} on PlatformException catch (e) {
print(e);
setState(() {
_isAuthenticating = false;
_authorized = ‘Error – ${e.message}’;
});
return;
}
if (!mounted) {
return;
}
final String message = authenticated ? ‘Authorized’ : ‘Not Authorized’;
setState(() {
_authorized = message;
});
}
Future<void> _cancelAuthentication() async {
await auth.stopAuthentication();
setState(() => _isAuthenticating = false);
}

D) Real-time view in iOS and Android

Biometric authentication integration

  • Implemented logic to set a unique global variable to get the real-time data or updates.
  • Managed to check the supported authentication system and flow for iOS and Android.
  • Managed the secure authentication and cancel flow based on the managed navigation.
  • Real-time authentication prompt in real iOS and Android devices.

Scalability and Performance Best Practices

1. Efficient Biometric State Management:

  • Utilized Riverpod, Provider, or Bloc for managing authentication state efficiently, preventing unnecessary re-renders.
  • Implemented lazy authentication requests, triggering biometric verification only when required instead of keeping it active in the background.
  • Cached biometric session data securely in Flutter Secure Storage to reduce redundant authentication requests

2. Optimized Native API Calls for Faster Authentication

  • Used Flutter’s local_auth plugin with optimized calls to Android’s BiometricPrompt and iOS’s LocalAuthentication API for minimal processing overhead.
  • Enabled asynchronous biometric verification, allowing UI updates while authentication is in progress to prevent freezing.
  • Reduced latency by preloading authentication logic when the app initializes, improving user experience.

3. Secure & Scalable Key Management

  • Stored biometric authentication keys securely using Android Keystore & iOS Keychain via platform channels.
  • Ensured end-to-end encryption when transmitting authentication responses between the app and backend servers.

4. Adaptive Authentication for High Performance

  • Dynamically adjusted biometric authentication methods based on device capability, ensuring compatibility across different hardware.
  • Implemented background biometric verification for high-risk transactions, reducing the need for frequent full authentications.

These optimizations ensure fast, scalable, and secure biometric authentication while maintaining a seamless user experience in Flutter apps.

Enable Biometric Login for Smarter App Security

The Way Forward

Incorporating Flutter Dart with a robust biometric authentication system for Android and iOS has elevated both security and user experience. From seamless fingerprint and facial recognition to secure session management and multi-factor authentication, this integration ensures privacy, compliance, and convenience. With adaptive fallback methods and platform-specific encryption, the solution is future-ready, designed to protect sensitive user data while delivering smooth, intuitive access across all supported devices.

Free Consultation

    Lopa Das

    With over 13 years of experience, Lopa Das is a seasoned professional at iFlair Web Technologies Pvt Ltd, specializing in web and mobile app development. Her technical expertise spans across Laravel, PHP, CodeIgniter, CakePHP, React, Vue.js, Nuxt.js, iOS, Android, Flutter, and React Native. Known for her exceptional skills in team handling, client communication, presales, and risk analysis, Lopa ensures seamless project execution from start to finish. Her proficiency in Laravel CRM, Next.js, and mobile app development makes her a valuable asset in delivering robust, scalable solutions.



    MAP_New

    Global Footprints

    Served clients across the globe from38+ countries