2020-01-21 17:51:37 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2024-05-06 19:55:05 +00:00
|
|
|
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
|
2020-01-21 17:51:37 +00:00
|
|
|
|
|
|
|
class BiometricAuth {
|
2024-05-06 19:55:05 +00:00
|
|
|
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
|
2020-01-21 17:51:37 +00:00
|
|
|
|
|
|
|
Future<bool> isAuthenticated() async {
|
|
|
|
try {
|
2024-05-06 19:55:05 +00:00
|
|
|
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
|
|
|
|
return authenticated;
|
|
|
|
} catch (e) {
|
2020-01-21 17:51:37 +00:00
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-10 14:51:59 +00:00
|
|
|
Future<bool> canCheckBiometrics() async {
|
2024-05-06 19:55:05 +00:00
|
|
|
bool canAuthenticate;
|
2020-09-10 14:51:59 +00:00
|
|
|
try {
|
2024-05-06 19:55:05 +00:00
|
|
|
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
|
|
|
|
await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(0);
|
|
|
|
} catch (error) {
|
|
|
|
print("Exception checking support. $error");
|
|
|
|
canAuthenticate = false;
|
2020-09-10 14:51:59 +00:00
|
|
|
}
|
|
|
|
|
2024-05-06 19:55:05 +00:00
|
|
|
return canAuthenticate;
|
2020-09-10 14:51:59 +00:00
|
|
|
}
|
2024-04-25 00:00:53 +00:00
|
|
|
}
|