Skip to main content

flutter_bio_auth 0.1.0 copy "flutter_bio_auth: ^0.1.0" to clipboard
flutter_bio_auth: ^0.1.0 copied to clipboard

On-device face detection, tracking, active liveness challenges, and an injectable 1:1 face-recognition / anti-spoof pipeline for Flutter. Detection/tracking/liveness work with zero bundled AI models ( [...]

example/lib/main.dart

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

import 'pages/home_page.dart';

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

class FaceBiometricExampleApp extends StatefulWidget {
  const FaceBiometricExampleApp({super.key});

  @override
  State<FaceBiometricExampleApp> createState() =>
      _FaceBiometricExampleAppState();
}

class _FaceBiometricExampleAppState extends State<FaceBiometricExampleApp> {
  late final Future<void> _initFuture;

  @override
  void initState() {
    super.initState();
    _initFuture = FaceBiometric.initialize(
      config: const FaceBiometricConfig(
        recognitionThreshold: 0.65,
        livenessThreshold: 0.80,
        antiSpoofThreshold: 0.80,
        enableLiveness: true,
        // Anti-spoofing is off by default in the example so it runs
        // out of the box without a bundled model. Turn this on (and
        // set antiSpoofModelAssetPath) once you've added a real
        // model -- see the root README.
        enableAntiSpoofing: false,
        authenticationMode: FaceAuthenticationMode.faceWithLiveness,
        randomizeChallenges: true,
        challenges: <LivenessChallenge>[
          LivenessChallenge.blink,
          LivenessChallenge.turnLeft,
          LivenessChallenge.turnRight,
        ],
        // Bundled MobileFaceNet model (112x112 RGB, 192-d output)
        // enables real face recognition, enrollment, and comparison!
        embeddingModelAssetPath: 'assets/models/mobilefacenet.tflite',
        antiSpoofModelAssetPath: null,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Face Biometric Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF3F5AA6)),
        useMaterial3: true,
      ),
      home: FutureBuilder<void>(
        future: _initFuture,
        builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
          if (snapshot.connectionState != ConnectionState.done) {
            return const Scaffold(
              body: Center(child: CircularProgressIndicator()),
            );
          }
          if (snapshot.hasError) {
            return Scaffold(
              body: Center(
                child: Padding(
                  padding: const EdgeInsets.all(24),
                  child: Text(
                    'Failed to initialize flutter_bio_auth:\n${snapshot.error}',
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
            );
          }
          return const HomePage();
        },
      ),
    );
  }
}
2
likes
130
points
165
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

On-device face detection, tracking, active liveness challenges, and an injectable 1:1 face-recognition / anti-spoof pipeline for Flutter. Detection/tracking/liveness work with zero bundled AI models (native ML Kit on Android, Vision framework on iOS). Recognition and passive anti-spoofing are model-driven and loaded from a developer-supplied asset path at initialize() time.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, flutter, plugin_platform_interface

More

Packages that depend on flutter_bio_auth

Packages that implement flutter_bio_auth