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

  • x 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.