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

A highly customizable and responsive biometric authentication package for Flutter supporting Fingerprint, FaceID, and TouchID on Android and iOS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mu_biometric_auth/mu_biometric_auth.dart';

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

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

  @override
  Widget build(BuildContext context) {
    // ScreenUtilInit is required for responsive UI
    return ScreenUtilInit(
      designSize: const Size(360, 690),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return MaterialApp(
          title: 'Mu Biometric Auth Demo',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          home: const MyHomePage(title: 'Biometric Auth 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> {
  String _authMessage = 'Not Authenticated';

  Future<void> _authenticate() async {
    final success = await BiometricService.instance.authenticate(
      reason: 'Please authenticate to access your secure dashboard.',
    );
    if (success) {
      if (mounted) {
        setState(() {
          _authMessage = 'Authenticated! ✅';
        });
      }
    } else {
      if (mounted) {
        setState(() {
          _authMessage = 'Authentication Failed ❌';
        });
      }
    }
  }

  @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>[
            const Icon(Icons.security, size: 80, color: Colors.deepPurple),
            const SizedBox(height: 24),
            Text(
              'Authentication Status:',
              style: Theme.of(context).textTheme.headlineSmall,
            ),
            const SizedBox(height: 8),
            Text(
              _authMessage,
              style: Theme.of(context).textTheme.bodyLarge?.copyWith(
                    fontWeight: FontWeight.bold,
                    color: _authMessage.contains('✅') ? Colors.green : Colors.grey,
                  ),
            ),
            const SizedBox(height: 40),
            ElevatedButton.icon(
              onPressed: _authenticate,
              icon: const Icon(Icons.lock_open),
              label: const Text('Unlock with Biometrics'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
130
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

A highly customizable and responsive biometric authentication package for Flutter supporting Fingerprint, FaceID, and TouchID on Android and iOS.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

cupertino_icons, flutter, flutter_screenutil, google_fonts, local_auth, lottie

More

Packages that depend on mu_biometric_auth