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

une bibliotheque flutter pour l'authentification par empreinte digitale.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test Auth Empreinte',
      home: const FingerprintTestPage(),
    );
  }
}

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

  @override
  State<FingerprintTestPage> createState() => _FingerprintTestPageState();
}

class _FingerprintTestPageState extends State<FingerprintTestPage> {
  final FingerprintAuth _fingerprintAuth = FingerprintAuth();
  String _status = "Appuyez sur un bouton pour tester.";

  Future<void> _checkBiometric() async {
    bool available = await _fingerprintAuth.isBiometricAvailable();
    setState(() {
      _status = available
          ? "Biométrie disponible sur cet appareil."
          : "Biométrie NON disponible.";
    });
  }

  Future<void> _testAuth() async {
    bool available = await _fingerprintAuth.isBiometricAvailable();
    if (!available) {
      setState(() {
        _status = "Biométrie non disponible sur cet appareil.";
      });
      return;
    }
    bool authenticated = await _fingerprintAuth.authenticate();
    setState(() {
      _status = authenticated
          ? "Authentification réussie !"
          : "Échec de l'authentification.";
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Test Auth Empreinte')),
      body: Center(child: Text(_status, textAlign: TextAlign.center)),
      floatingActionButton: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          FloatingActionButton.extended(
            onPressed: _checkBiometric,
            label: const Text("Vérifier la biométrie"),
            icon: const Icon(Icons.info),
            heroTag: "check_bio",
          ),
          const SizedBox(height: 16),
          FloatingActionButton(
            onPressed: _testAuth,
            child: const Icon(Icons.fingerprint),
            heroTag: "auth",
          ),
        ],
      ),
    );
  }
}
1
likes
140
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

une bibliotheque flutter pour l'authentification par empreinte digitale.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, local_auth

More

Packages that depend on empreinte_auth