flutter_biometric_auth 0.0.1
flutter_biometric_auth: ^0.0.1 copied to clipboard
Flutter plugin for Face ID and Touch ID authentication. This plugin uses the LocalAuthentication package to authenticate users with Face ID or Touch ID on iOS
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:faceid/faceid.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _faceidPlugin = Faceid();
bool _isAuthenticated = false;
void _authenticate() async {
try {
final isAuthenticated = await _faceidPlugin.authenticate();
setState(() {
_isAuthenticated = isAuthenticated;
});
} on PlatformException catch (e) {
log('Failed to authenticate: ${e.message}', error: e);
}
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
InkWell(
onTap: _authenticate,
child: const Text('Tap to get access'),
),
_isAuthenticated
? const Text('Authenticated')
: const Text('Not authenticated'),
],
),
),
),
);
}
}