flutter_liveness_detection 0.0.3 copy "flutter_liveness_detection: ^0.0.3" to clipboard
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.


pub package Pub Points Likes GitHub Repo


πŸš€ 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'),
)



2
likes
0
points
167
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for real-time liveness detection using face gestures like smile, blink, and head movement. Supports Android and iOS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera, cupertino_icons, flutter, google_mlkit_face_detection, permission_handler

More

Packages that depend on flutter_liveness_detection