What local_auth Does and Doesn't Do
The local_auth package wires the device's OS-level biometric authentication (BiometricPrompt on Android, Face ID/Touch ID on iOS) into Flutter. There's an important distinction: local_auth never hands your Flutter app the actual fingerprint data or face map — it only answers yes/no to 'did this device's owner just verify their identity?'. The real biometric data always stays in the device's secure hardware (Secure Enclave, TEE).
Checking Device Support
Before calling authenticate(), you should check whether the device supports biometrics and whether the user has at least one biometric enrolled.
final auth = LocalAuthentication();
Future<bool> biyometriKullanilabilirMi() async {
final desteklerMi = await auth.isDeviceSupported();
final kayitVarMi = await auth.canCheckBiometrics;
return desteklerMi && kayitVarMi;
}
Sending an Authentication Request
authenticate() shows the user the OS's own biometric screen and returns a bool. localizedReason is the explanation text shown to the user on that screen.
Future<bool> girisYap() async {
try {
return await auth.authenticate(
localizedReason: 'Hesabınıza erişmek için kimliğinizi doğrulayın',
options: const AuthenticationOptions(
biometricOnly: true,
stickyAuth: true,
),
);
} on PlatformException catch (e) {
debugPrint('Dogrulama hatasi: ${e.code}');
return false;
}
}
biometricOnly: true prevents the user from falling back to the device PIN/pattern — only fingerprint or face recognition is accepted. stickyAuth: true keeps the authentication request open even if the app goes to the background and comes back.
Listing Available Methods with BiometricType
You can find out which biometric methods are enrolled on the device (fingerprint, face, iris) with getEnrolledBiometrics, and tailor your UI accordingly (e.g. a 'Sign in with Face ID' label).
final yontemler = await auth.getEnrolledBiometrics();
if (yontemler.contains(BiometricType.face)) {
// 'Face ID ile Giriş Yap' göster
}
Platform Configuration
On Android, you need to add the USE_BIOMETRIC permission to AndroidManifest.xml, and MainActivity must extend FlutterFragmentActivity. On iOS, you must add an NSFaceIDUsageDescription key to Info.plist explaining why Face ID is requested; without it, the Face ID request silently fails.
Things to Watch Out For
1. Biometrics Alone Isn't Encryption
A true return from authenticate() means 'the device's owner was verified' — don't rely on that result to store sensitive data (tokens, passwords) in plain text. Tokens should still live in an encrypted store like flutter_secure_storage; think of biometrics as just the lock that unlocks access to that store.
2. Falling Back to a PIN on Failure
If biometricOnly is left false (the default), the OS offers the device PIN/pattern after a few failed biometric attempts. This rescues the user from getting locked out when the biometric sensor temporarily doesn't work (a wet finger, a face covered by a mask, etc.).
Conclusion
local_auth brings the OS's ready-made biometric screen into your app without you building complex security infrastructure. Check support first with isDeviceSupported and canCheckBiometrics, send the request with authenticate(), and never treat the result as proof of authorization on its own — use it only as the lock that unlocks access to sensitive data.




