flutter_face_liveness library

Flutter Face Liveness — AI-powered face detection, liveness verification, and anti-spoof protection using Google ML Kit + optional TFLite.

Quick start

import 'package:flutter_face_liveness/flutter_face_liveness.dart';

FlutterFaceLiveness(
  actions: [LivenessAction.blink, LivenessAction.turnLeft, LivenessAction.smile],
  config: LivenessConfig(
    randomizeActions: true,
    enableAntiSpoof: true,
  ),
  onSuccess: (result) {
    print('Verified — session: ${result.sessionId}');
    print('Confidence: ${result.confidenceScore}');
  },
  onFailed: (reason) => print('Failed: $reason'),
)

Classes

AntiSpoofEngine
Multi-signal heuristic anti-spoof engine.
AntiSpoofResult
Composite anti-spoofing result.
FaceCaptureResult
Outcome of FaceCaptureService.captureAndIdentify.
FaceCaptureService
Orchestrates the "capture a still photo → detect → quality-gate → align → embed → match/register" flow — the counterpart to LivenessController's live-frame identity pipeline, for apps that want enrollment/verification from a single captured picture rather than a full liveness session.
FaceData
Processed face data extracted from ML Kit detection result.
FaceIdentityService
Persistent face-identity service.
FaceMatchResult
Rich result returned by FaceIdentityService.identifyFromEmbeddings.
FaceMeshData
Processed data derived from the 468-landmark MediaPipe Face Mesh model.
FaceModelDownloader
Downloads and caches the FaceNet TFLite model on first use.
FlutterFaceLiveness
Top-level widget for face liveness verification.
FrameQuality
Quality metrics computed from a raw camera frame in a background isolate.
LivenessConfig
Full configuration for the liveness verification session.
LivenessController
ChangeNotifier that drives the full liveness verification session.
LivenessResult
Result returned when a liveness verification session ends.
RawFrameData
Raw frame metadata forwarded to FaceIdentityService when enableFaceId is on.
SessionManager
Manages per-session metadata for audit trails and replay-attack prevention.
TFLiteModelDownloader
Downloads and caches a TFLite anti-spoof model on first use.
TFLiteService
Loads and runs a TensorFlow Lite anti-spoof model in a background isolate.
YoloFaceDetection
One detected face from YoloFaceDetectorService.
YoloFaceDetectorService
Runs a YOLOv8n-face TFLite model in a background isolate.
YoloModelDownloader
Downloads and caches the YOLOv8n-face TFLite model on first use.

Enums

DetectionStatus
All possible states the liveness engine can be in.
FaceDetectorBackend
Selects which model powers face detection for the identity/recognition pipeline (embedding + matching always run through FaceEmbeddingModel regardless of this choice).
FaceDetectorMode
Option for controlling additional trade-offs in performing face detection.
FaceIdMode
Controls how FaceIdentityService behaves when a new embedding arrives.
FaceMatchOutcome
Outcome of a single FaceIdentityService.identifyFromEmbeddings call.
LivenessAction
All supported liveness challenge actions.

Typedefs

LandmarkPoint = ({double x, double y})
2-D point for face landmark positions, expressed in image-pixel coordinates.