๐ก๏ธ Simple Local Auth
A lightweight and developer-friendly Flutter plugin to authenticate users using local biometric methods such as Fingerprint, Face ID, and other platform-specific mechanisms.
โจ Features
- Check biometric hardware availability
- Detect enrolled biometrics
- Support for Fingerprint and Face ID
- Simple API to trigger biometric authentication
- Smooth integration for Android and iOS
๐ฆ Installation
Add the package to your pubspec.yaml:
dependencies:
simple_local_auth: ^1.0.0
Then run:
flutter pub get
โ๏ธ Platform Setup
Android
- Update your
android/app/build.gradle:
minSdkVersion 23
- Add permissions to
AndroidManifest.xml(usually not required, but ensure biometric support is enabled):
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
iOS
- Add the following to your
Info.plist:
<key>NSFaceIDUsageDescription</key>
<string>This app uses Face ID to authenticate the user</string>
- Ensure your app has a Deployment Target of iOS 11.0+ in
ios/Podfile.
๐ Getting Started
Import the package
import 'package:simple_local_auth/simple_local_auth.dart';
import 'package:simple_local_auth/models/auth_results.dart';
Check Biometric Availability
final availability = await SimpleLocalAuth.getAvailabilityDetails();
if (availability.hasHardware && availability.hasEnrolledBiometrics) {
// Safe to prompt for authentication
}
Authenticate User
final result = await SimpleLocalAuth.authenticate(
reason: 'Please authenticate to proceed',
cancelButton: 'Cancel',
);
if (result.success) {
// Authentication successful
} else {
// Handle failure
}
๐งช Example App
A full-featured example is included in the example/ directory.
Run it:
cd example
flutter run
The app shows:
- Biometric availability
- Authentication status
- Feedback on success/failure
๐ท UI Preview
โ Capabilities Checked
- Hardware Availability โ
- Biometrics Enrolled โ
- Fingerprint Support โ
- Face ID Support โ
๐ Notes
- On some Android devices, users must manually enroll biometrics.
- On iOS, make sure Face ID/Touch ID is configured in device settings.
๐ค Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch
- Submit a pull request with a clear description
๐ License
MIT License
Built with โค๏ธ by [Tamremariam Belete].