cake_wallet/lib/entities/biometric_auth.dart
Matthew Fosse e5be737236
bio auth on mac + package updates for 3.19.3/5 (#1398)
* bio auth mac fix

* remove comment and change duration from 2 to 0

* cherry pick previous changes

* workaround for secure storage bug on mac

* bump version to 3.19.5 (because breez will need this version anyways)

* some code cleanup

* some changess didn't get saved

* just documenting the issue [skip ci]

* undo accidental removal + minor code cleanup

* merge conflicts

* Minor UI change [skip ci]

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-06 22:55:05 +03:00

29 lines
No EOL
849 B
Dart

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;
}
Future<bool> canCheckBiometrics() async {
bool canAuthenticate;
try {
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(0);
} catch (error) {
print("Exception checking support. $error");
canAuthenticate = false;
}
return canAuthenticate;
}
}