flutter_liveness_plugin 0.0.11
flutter_liveness_plugin: ^0.0.11 copied to clipboard
Android Only plugin that uses Google ML Kit to determine if the person in the view port is human or not.
Flutter Liveness Plugin #
flutter_liveness_plugin is a Flutter plugin built specifically for Android, designed to perform real-time liveness detection using Google ML Kit and the device camera. This plugin is ideal for scenarios requiring secure identity verification, such as KYC processes, biometric login, or authentication systems.
β οΈ iOS support is currently under development.
π Platform Support #
Platform | Supported |
---|---|
Android | β Yes |
iOS | π§ In Progress |
Web | β No |
Desktop | β No |
π Installation #
Add the plugin to your Flutter project:
dependencies:
flutter_liveness_plugin: ^0.0.8
Then run:
flutter pub get
π Plugin Capabilities #
This plugin performs real-time liveness detection using the front-facing camera, leveraging ML Kit's face detection API.
β Features: #
- Blink detection
- Smile detection
- On-device processing
- Returns path to captured image (if detection is successful)
πΈ Basic Usage #
1. Import the package #
import 'package:flutter_liveness_plugin/flutter_liveness_plugin.dart';
2. Start liveness detection #
String? imagePath = (await FlutterLivenessPlugin.captureLiveImage());
if (imagePath != null && imagePath.isNotEmpty) {
print("Liveness passed. Image path: $imagePath");
} else {
print("Liveness check failed or was cancelled.");
}
π What You Get #
If liveness validation is successful, the method returns a String path to the captured image.
π Required Android Permissions #
You must add camera permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.CAMERA" />
Also ensure you request permissions at runtime using a package like permission_handler
.
π¦ How It Works Internally #
- Uses CameraX to open the front-facing camera
- Applies ML Kitβs Face Detection to identify facial features
- Tracks eye movement and smiling patterns
- Validates liveness based on blink and smile conditions
- Captures and stores the validated image locally
- Returns the image file path via
MethodChannel
π§ͺ Example #
The plugin includes a working example app located in the example/
directory. To try it out:
cd example
flutter run
π Privacy and Security #
- All face processing is done entirely on-device.
- No internet access is used for detection.
- No images or video frames are uploaded or shared.
- The captured image is stored locally and accessible to your app.
π Roadmap #
- β Android support
- β iOS support (in progress)
- β More advanced spoofing checks (e.g. depth, light reflection)
- β Configurable detection thresholds
π Contributing #
We welcome contributions! Feel free to:
- Submit a pull request
- File an issue
- Suggest enhancements
π License #
This project is licensed under the MIT License.
Made with β€οΈ by Sahil K.