ultimate_liveliness_detector 1.0.1
ultimate_liveliness_detector: ^1.0.1 copied to clipboard
A Flutter plugin for face liveness detection with configurable tasks (Smile, Blink, Motion). Uses ML Kit for face detection.
import 'package:flutter/material.dart';
import 'package:ultimate_liveliness_detector/liveness_detection.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Liveness Detection Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.teal, useMaterial3: true),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Liveness Detection Example')),
body: Center(
child: ElevatedButton(
onPressed: () => _startVerification(context),
child: const Text('Start Liveness Verification'),
),
),
);
}
void _startVerification(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LivenessDetection(
config: LivenessConfig(
enableSmile: true,
enableBlink: true,
enableMotion: true,
requiredDetections: 10,
requiredBlinks: 3,
showDefaultSuccessScreen: true,
onSuccess: (imagePath) {
debugPrint('Liveness verification successful! Image: $imagePath');
},
onCancel: () {
Navigator.pop(context);
},
),
),
),
);
}
}