liveness_capture 0.0.7 copy "liveness_capture: ^0.0.7" to clipboard
liveness_capture: ^0.0.7 copied to clipboard

A Flutter package for face liveness detection with configurable challenge types and auto-capture. Detect real human presence using smile, blink, and head turns.

image

A highly customizable Flutter package for face liveness detection with configurable challenge types and auto-capture. Detect real human presence — not a photo, video, or mask — using challenges like smile, blink, and head turns, with animated visual feedback and built-in photo capture on success.

Features #

  • Real-time face detection via Google ML Kit
  • Configurable liveness rule set: smile, blink, look left/right, tilt up/down
  • Animated dotted-circle progress indicator around the face frame
  • Auto face-centering guidance
  • Captures a photo after all liveness rules are passed
  • Customizable colors, sizes, and UI overlays

Platform Support #

Android iOS

Permissions #

Add the following to your platform manifests:

Androidandroid/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

iOSios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app uses the camera for liveness detection.</string>

Installation #

Add to your pubspec.yaml:

dependencies:
  liveness_capture: ^0.0.1

Then run:

flutter pub get

Usage #

import 'package:liveness_capture/liveness_capture.dart';

FaceDetectorScreen(
  // Called each time a liveness rule is completed
  onRulesetCompleted: (ruleset) {
    print('Completed: $ruleset');
  },
  // Called when all rules pass; provides the CameraController for capture
  onValidationDone: (controller) {
    return ElevatedButton(
      onPressed: () async {
        final photo = await controller?.takePicture();
        // handle photo
      },
      child: const Text('Capture'),
    );
  },
  // Builder for the overlay shown during liveness checks
  child: ({required state, required countdown, required hasFace}) {
    return Text(
      hasFace ? 'Hold still... $countdown' : 'Place your face in frame',
      style: const TextStyle(color: Colors.white, fontSize: 18),
    );
  },
);

Customisation #

Parameter Type Description
ruleset List<Rulesets> Ordered list of liveness checks to perform
progressColor Color Inactive dot color
activeProgressColor Color Active/completed dot color
totalDots int Number of dots in the circle
dotRadius double Radius of each dot
cameraSize Size Size of the camera preview frame
pauseDurationInSeconds int Pause between ruleset steps
backgroundColor Color? Background color of the detector
contextPadding EdgeInsetsGeometry? Padding around the content

Available Rulesets #

enum Rulesets { toLeft, toRight, blink, tiltUp, tiltDown, smiling, normal }

License #

MIT

4
likes
160
points
293
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for face liveness detection with configurable challenge types and auto-capture. Detect real human presence using smile, blink, and head turns.

Repository (GitHub)
View/report issues

Topics

#face-detection #liveness #camera #biometrics #photo

License

MIT (license)

Dependencies

camera, camera_android, camera_avfoundation, flutter, google_mlkit_commons, google_mlkit_face_detection, permission_handler

More

Packages that depend on liveness_capture