Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
biometric_service.dart
Go to the documentation of this file.
1import 'package:local_auth/local_auth.dart';
2
3abstract class BiometricService {
4 Future<List<BiometricType>> getAvailableBiometrics();
5 Future<bool> authenticate(BiometricType type, String reason);
6 Future<bool> hasFingerprintSupport();
7}
8
11
12 final _localAuth = LocalAuthentication();
13
14 @override
15 Future<List<BiometricType>> getAvailableBiometrics() async {
16 try {
17 return await _localAuth.getAvailableBiometrics();
18 } catch (e) {
19 return [];
20 }
21 }
22
23 @override
24 Future<bool> authenticate(BiometricType type, String reason) async {
25 try {
26 return await _localAuth.authenticate(
27 localizedReason: reason,
28 options: const AuthenticationOptions(stickyAuth: true),
29 );
30 } catch (e) {
31 return false;
32 }
33 }
34
35 @override
36 Future<bool> hasFingerprintSupport() async {
37 try {
38 final biometrics = await getAvailableBiometrics();
39 return biometrics.contains(BiometricType.fingerprint) || biometrics.contains(BiometricType.strong);
40 } catch (e) {
41 return false;
42 }
43 }
44}
abstract class BiometricService LocalBiometricService()
final _localAuth
Future< List< BiometricType > > getAvailableBiometrics()
Future< bool > hasFingerprintSupport()
Future< bool > authenticate(BiometricType type, String reason)
final String type
class Partner String