cake_wallet/lib/entities/biometric_auth.dart

31 lines
898 B
Dart
Raw Normal View History

import 'package:flutter/services.dart';
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
class BiometricAuth {
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
Future<bool> isAuthenticated() async {
try {
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
return authenticated;
} catch (e) {
print(e);
}
return false;
}
2020-09-10 14:51:59 +00:00
Future<bool> canCheckBiometrics() async {
bool canAuthenticate;
2020-09-10 14:51:59 +00:00
try {
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
2024-04-18 19:13:12 +00:00
// Setup TouchID Allowable Reuse duration
await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(2);
} catch (error) {
print("Exception checking support. $error");
canAuthenticate = false;
2020-09-10 14:51:59 +00:00
}
return canAuthenticate;
2020-09-10 14:51:59 +00:00
}
}