Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
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) ||
40 biometrics.contains(BiometricType.strong);
41 } catch (e) {
42 return false;
43 }
44 }
45}
abstract class BiometricService LocalBiometricService()
final _localAuth
Future< List< BiometricType > > getAvailableBiometrics()
Future< bool > hasFingerprintSupport()
Future< bool > authenticate(BiometricType type, String reason)
class EnergySavingsMeasure extends StatefulWidget options