empire_auth_biometric 0.0.1 copy "empire_auth_biometric: ^0.0.1" to clipboard
empire_auth_biometric: ^0.0.1 copied to clipboard

PlatformAndroid

Un plugin Flutter pour l'authentification biométrique (empreinte digitale ou reconnaissance faciale) sur Android, utilisant les API AndroidX Biometric. Permet une intégration rapide et fluide de la b [...]

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: BiometricDemoPage(),
    );
  }
}

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

  @override
  State<BiometricDemoPage> createState() => _BiometricDemoPageState();
}

class _BiometricDemoPageState extends State<BiometricDemoPage> {
  final _biometric = EmpireAuthBiometric();

  String _status = 'Vérification en cours...';
  String _authResult = 'Pas encore testé.';

  @override
  void initState() {
    super.initState();
    _checkBiometricStatus();
  }

  Future<void> _checkBiometricStatus() async {
    try {
      final status = await _biometric.checkBiometricStatus();
      setState(() {
        _status = '${status.status.name.toUpperCase()} : ${status.message}';
      });
    } catch (e) {
      setState(() {
        _status = 'Erreur lors de la vérification : $e';
      });
    }
  }

  Future<void> _authenticate() async {
    try {
      final result = await _biometric.authenticate(
        title: 'Connexion sécurisée',
        subtitle: 'Confirmez votre identité avec la biométrie',
        negativeButtonText: 'Annuler',
      );

      setState(() {
        if (result.success) {
          _authResult = '✅ Succès : ${result.message}';
        } else {
          _authResult =
          '❌ Échec : ${result.message} (${result.errorType?.name ?? "inconnu"})';
        }
      });
    } catch (e) {
      setState(() {
        _authResult = 'Erreur pendant l\'authentification : $e';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Empire Auth Biometric Demo'),
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Card(
              color: Colors.grey.shade100,
              child: Padding(
                padding: const EdgeInsets.all(16),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const Text('📲 Statut biométrique:',
                        style: TextStyle(fontWeight: FontWeight.bold)),
                    const SizedBox(height: 8),
                    Text(_status),
                  ],
                ),
              ),
            ),
            const SizedBox(height: 20),
            ElevatedButton.icon(
              onPressed: _checkBiometricStatus,
              icon: const Icon(Icons.search),
              label: const Text('Vérifier le statut'),
            ),
            const SizedBox(height: 12),
            ElevatedButton.icon(
              onPressed: _authenticate,
              icon: const Icon(Icons.fingerprint),
              label: const Text('S\'authentifier'),
            ),
            const SizedBox(height: 20),
            Card(
              color: Colors.grey.shade100,
              child: Padding(
                padding: const EdgeInsets.all(16),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const Text('🔐 Résultat d\'authentification:',
                        style: TextStyle(fontWeight: FontWeight.bold)),
                    const SizedBox(height: 8),
                    Text(_authResult),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
140
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

Un plugin Flutter pour l'authentification biométrique (empreinte digitale ou reconnaissance faciale) sur Android, utilisant les API AndroidX Biometric. Permet une intégration rapide et fluide de la biométrie dans vos applications Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on empire_auth_biometric

Packages that implement empire_auth_biometric