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