DEV Community

Sushant Kumar
Sushant Kumar

Posted on

How to Add Face Liveness Detection to Flutter in 5 Minutes

Spoofing attacks — where someone holds up a photo or plays a video to trick your face verification — are a real problem for mobile apps.

In this post I'll show you how to add passive face liveness detection to a Flutter app in under 5 minutes using FaceNova SDK.

What is passive liveness detection?

Unlike active liveness (where the user has to blink, smile or turn their head), passive liveness works silently from a single frame. The user just looks at the camera — no instructions needed.

FaceNova's on-device AI model detects:

  • ✅ Printed photo attacks
  • ✅ Video replay attacks (phone/tablet/laptop screen)
  • ✅ 3D mask attacks

All processing runs on-device. No face images sent to any server. GDPR compliant by design.


Step 1 — Add the dependency


dependencies:
flutter_face_nova:
git:
url: https://github.com/facenova/flutter_face_nova.git
permission_handler: ^11.4.0

Step 2 — Initialize on startup


void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterFaceNova.initialize(licenseKey: 'YOUR_LICENSE_KEY');
await Permission.camera.request();
runApp(MyApp());
}

Step 3 — Launch liveness check


final LivenessResult? result = await FlutterFaceNova.startLiveness(context);

if (result == null) return; // user cancelled

if (result.isReal) {
print('Real face: ${(result.score * 100).toStringAsFixed(1)}%');
} else {
print('Spoof detected!');
}

That's it. Three steps.



Bonus — Face matching in the same camera session

final FaceMatchResult? match = await FlutterFaceNova.startLivenessAndMatch(
context,
enrolledFaces: myEnrolledFaces,
matchThreshold: 75.0,
);

if (match != null && match.isMatch) {
print('Identity verified: ${match.matchedFace?.name}');
}


Why FaceNova?
✅ Works offline — Fully functional without an active internet connection.

✅ No cloud / server — Complete data privacy with zero external dependencies.

✅ GDPR compliant — Built with privacy-by-design standards.

✅ Passive execution — Seamless checks with zero mandatory user actions.

✅ Face matching included — Built-in identity verification alongside liveness scanning.

✅ Cross-platform — Native performance tailored for Flutter, Android, and iOS.


Get a free 10-day trial

👉 https://facenova.uk

No credit card required. Lifetime license from $10 for one app.

Top comments (0)