2024-04-18 18:10:58 +00:00
|
|
|
import 'package:local_auth/local_auth.dart';
|
2020-01-21 17:51:37 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2024-04-18 18:10:58 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-01-21 17:51:37 +00:00
|
|
|
|
|
|
|
class BiometricAuth {
|
2024-04-18 18:10:58 +00:00
|
|
|
final _localAuth = LocalAuthentication();
|
2020-01-21 17:51:37 +00:00
|
|
|
|
|
|
|
Future<bool> isAuthenticated() async {
|
|
|
|
try {
|
2024-04-18 18:10:58 +00:00
|
|
|
return await _localAuth.authenticate(
|
|
|
|
localizedReason: S.current.biometric_auth_reason,
|
|
|
|
options: AuthenticationOptions(
|
|
|
|
biometricOnly: true,
|
|
|
|
useErrorDialogs: true,
|
|
|
|
stickyAuth: false));
|
|
|
|
} on PlatformException catch (e) {
|
2020-01-21 17:51:37 +00:00
|
|
|
print(e);
|
|
|
|
}
|
2024-04-18 18:10:58 +00:00
|
|
|
|
2020-01-21 17:51:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-10 14:51:59 +00:00
|
|
|
Future<bool> canCheckBiometrics() async {
|
|
|
|
try {
|
2024-04-18 18:10:58 +00:00
|
|
|
return await _localAuth.canCheckBiometrics;
|
|
|
|
} on PlatformException catch (e) {
|
|
|
|
print(e);
|
2020-09-10 14:51:59 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 18:10:58 +00:00
|
|
|
return false;
|
2020-09-10 14:51:59 +00:00
|
|
|
}
|
|
|
|
}
|