2024-12-09 18:23:59 +00:00
|
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
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) {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV(e);
|
2020-01-21 17:51:37 +00:00
|
|
|
}
|
|
|
|
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) {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV("Exception checking support. $error");
|
2024-05-06 19:55:05 +00:00
|
|
|
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
|
|
|
}
|