local_auth
3.0.2, released 4 months ago by flutter.dev
Flutter plugin for on‑device authentication using biometrics, PIN, pattern or passcode.
What it does
Provides a unified API to check device authentication capabilities and to prompt the user for biometric or device‑level authentication. It abstracts platform‑specific implementations for Android, iOS, macOS and Windows. Errors are returned as structured LocalAuthException codes.
AI-written summary of version 3.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need local, on‑device authentication without a backend
- You want biometric, face, fingerprint or fallback PIN/passcode support across mobile and desktop
- You require a simple API to check enrollment and authenticate the user
Skip it when
- Your app targets web platforms
- You need social or OAuth based sign‑in flows
- You require server‑side token validation
Strengths
- Native biometric and device‑level authentication on multiple platforms
- Fallback to PIN/pattern/passcode when biometrics unavailable
- Clear error handling with LocalAuthException codes
- Simple, synchronous‑style API
Weaknesses
- No web support
- Requires native setup and permissions per platform
- Windows cannot enforce biometric‑only authentication
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 4
Add local_auth and platform packages to pubspec, configure Android manifest (USE_BIOMETRIC permission), iOS Info.plist (NSFaceIDUsageDescription), and follow platform‑specific README links for additional steps.
import 'package:local_auth/local_auth.dart';
final LocalAuthentication auth = LocalAuthentication();
final bool canAuth = await auth.canCheckBiometrics || await auth.isDeviceSupported();
if (canAuth) {
final bool didAuth = await auth.authenticate(
localizedReason: 'Please authenticate to continue',
biometricOnly: true,
);
// proceed based on didAuth
}Alternatives
Packages that do the same job and could replace local_auth.
- google_sign_in
Provides Google OAuth sign‑in and works on web as well as mobile
84Compare - firebase_auth
Offers a full suite of authentication methods (email/password, social, anonymous) with server‑side token handling
99Compare
Works with
Packages commonly used together with local_auth: ones it builds on, ones built on it, and its own family.
- local_auth_androidlocal_auth depends on itAndroid implementation of the local_auth plugin for biometric authentication.
- local_auth_darwinlocal_auth depends on itiOS/macOS implementation of the local_auth plugin
- local_auth_windowslocal_auth depends on itWindows implementation of local_auth for biometric authentication
- king_cacheBuilt on local_authFile‑ and IndexedDB‑based cache for API responses and markdown content.
- webauthnBuilt on local_authA plugin implementing the WebAuthn authenticator model for generating Public Key Credentials