face_guard_liveness 1.0.2 copy "face_guard_liveness: ^1.0.2" to clipboard
face_guard_liveness: ^1.0.2 copied to clipboard

A production-ready Flutter SDK for real-time on-device face liveness detection and face verification using ML Kit and TFLite.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:face_guard_liveness/face_guard_liveness.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Face Liveness Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterialDesign3: true,
      ),
      home: const MyHomePage(title: 'Face Liveness Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  LivenessResult? _result;

  Future<void> _startLiveness() async {
    final result = await FaceGuardLiveness.startLivenessCheck(
      context,
      actions: [
        LivenessAction.blink,
        LivenessAction.smile,
        LivenessAction.turnLeft,
        LivenessAction.turnRight,
      ],
    );

    if (mounted) {
      setState(() {
        _result = result;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (_result != null) ...[
              Text(
                _result!.isLive ? 'Liveness Success!' : 'Liveness Failed',
                style: TextStyle(
                  fontSize: 24,
                  fontWeight: FontWeight.bold,
                  color: _result!.isLive ? Colors.green : Colors.red,
                ),
              ),
              if (_result!.failureReason != null)
                Text('Reason: ${_result!.failureReason}'),
              const SizedBox(height: 20),
              Text('Completed Actions: ${_result!.completedActions.length}'),
            ] else
              const Text('Press the button to start liveness check'),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _startLiveness,
        tooltip: 'Start',
        child: const Icon(Icons.camera_alt),
      ),
    );
  }
}
0
likes
0
points
54
downloads

Publisher

unverified uploader

Weekly Downloads

A production-ready Flutter SDK for real-time on-device face liveness detection and face verification using ML Kit and TFLite.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera, cupertino_icons, flutter, google_mlkit_commons, google_mlkit_face_detection, image, path, path_provider, tflite_flutter

More

Packages that depend on face_guard_liveness