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


πŸ“‹ Permissions & Requirements #

To use flutter_liveness_detection, ensure the following:

βœ… Android Requirements: #

  • Minimum SDK version: 21
  • Permissions Required: Add these to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.CAMERA"/>

πŸ› οΈ Quick Usage #

To trigger liveness detection, just call the widget inside a button press:

 ElevatedButton(
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.all(20),
                shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
                foregroundColor: Colors.black,
                backgroundColor: Colors.blueAccent,
              ),
              onPressed: () async {
                // Step 1: Get the list of available cameras on the device
                final List<CameraDescription> cameras = await availableCameras();

                // Step 2: Proceed only if there's at least one camera (front camera)
                if (cameras.isNotEmpty) {
                  // 🧠 You can set any 2 or more actions from below to verify the user is real.
                  // The user will be asked to perform these actions for verification.
                  List<Moment> challengeActions = [
                    Moment.smile,       // πŸ˜€ Ask user to smile
                    Moment.eyeblink,    // πŸ‘οΈ Ask user to blink
                    Moment.leftPose,    // πŸ‘ˆ Turn head left
                    Moment.rightPose,   // πŸ‘‰ Turn head right
                  ];

                  // Step 3: Start the liveness detection screen with defined actions, Call this widget 'FlutterLivenessDetection'
                  final XFile? result = await Navigator.push(context,
                    MaterialPageRoute(
                      builder: (context) => FlutterLivenessDetection(moments: challengeActions),
                    ),
                  );

                  // Step 4: If selfie is returned, that means verification passed
                  if (result != null) {
                    setState(() {
                      imageFile = File(result.path);
                    });

                    // Step 5: You can save/upload the image. Show success message.
                    print('Selfie path: ${result.path}');
                    ScaffoldMessenger.of(context).showSnackBar(
                      const SnackBar(content: Text('Verification Successful!')),
                    );
                  }
                } else {
                  // ❌ No camera found on device
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('Camera not active!')),
                  );
                }
              },
              child: const Text('Verify Now', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
            ),



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, camera_android_camerax, flutter, google_mlkit_face_detection, permission_handler

More

Packages that depend on flutter_liveness_detection