flutter_liveness_detection 0.0.3
flutter_liveness_detection: ^0.0.3 copied to clipboard
A Flutter plugin for real-time liveness detection using face gestures like smile, blink, and head movement. Supports Android and iOS.
π§ flutter_liveness_detection #
flutter_liveness_detection is a powerful and easy-to-integrate Flutter plugin that enables real-time liveness detection using the deviceβs front camera.
This plugin validates the presence of a live human being by detecting natural facial movements such as:
- ποΈ Eye Blinking
- π Smiling
- π Head movement (left and right)
Ideal for applications that require face-based identity verification, such as KYC, biometric login, or attendance systems.
π Features #
- β Detects facial movements to confirm user presence
- ποΈ Eye blink detection
- π Smile detection
- βοΈ Head movement detection (left & right)
- π₯ Front camera feed access
- π§ Real-time detection using optimized performance
- π± Supports both Android and iOS
- π οΈ Easy to integrate into any Flutter project
- π Ideal for security-focused use cases
π§ Getting Started #
π¦ Installation #
Add the package to your pubspec.yaml:
dependencies:
flutter_liveness_detection: ^0.0.3
π οΈ Quick Usage #
To trigger liveness detection, just call the widget inside a button press:
ElevatedButton(
onPressed: () async {
/// 1οΈβ£ Check if the device has any cameras.
/// (We need at least one front camera to run liveness detection)
final List<CameraDescription> cameras = await availableCameras();
if (cameras.isNotEmpty) {
/// 2οΈβ£ Open the liveness detection screen.
/// Call the **FlutterLivenessDetection** widget β this is required.
/// It will guide the user to blink, smile, or turn their head,
/// then take a selfie automatically.
final XFile? result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) => const FlutterLivenessDetection()),
);
/// 3οΈβ£ If detection was successful, you will get a selfie image.
if (result != null) {
/// 4οΈβ£ Print the selfie image path (you can upload or save this file).
print('Selfie path: ${result.path}');
/// 5οΈβ£ Show a success message to the user.
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Verification Successful!')),
);
}
} else {
/// β No camera found β Show an error message.
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Camera not active!')),
);
}
},
/// The button users click to start liveness detection.
child: const Text('Start Liveness Detection'),
)