-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbiometric.dart
More file actions
34 lines (31 loc) · 942 Bytes
/
biometric.dart
File metadata and controls
34 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'package:flutter/services.dart';
import 'package:local_auth/local_auth.dart';
class Biometric {
Biometric._privateConstructor();
static final Biometric instance = Biometric._privateConstructor();
final LocalAuthentication auth = LocalAuthentication();
Map<String,dynamic> rslt = {'status':false};
Future<Map> authenticate() async {
bool authenticated = false;
bool canCheckBiometrics;
try {
canCheckBiometrics = await auth.canCheckBiometrics;
} on PlatformException catch (e) {
print(e);
}
if (canCheckBiometrics) {
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Login into Scratch App',
useErrorDialogs: true,
stickyAuth: false);
rslt = {'status':authenticated};
} on PlatformException catch (e) {
print(e);
}
} else {
return rslt;
}
return rslt;
}
}