2020-01-21 19:51:37 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2024-04-18 10:00:24 -07:00
|
|
|
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
|
2020-01-21 19:51:37 +02:00
|
|
|
|
|
|
|
class BiometricAuth {
|
2024-04-18 10:00:24 -07:00
|
|
|
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
|
2020-01-21 19:51:37 +02:00
|
|
|
|
|
|
|
Future<bool> isAuthenticated() async {
|
|
|
|
try {
|
2024-04-18 10:00:24 -07:00
|
|
|
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
|
|
|
|
return authenticated;
|
|
|
|
} catch (e) {
|
2020-01-21 19:51:37 +02:00
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-10 17:51:59 +03:00
|
|
|
Future<bool> canCheckBiometrics() async {
|
2024-04-18 10:00:24 -07:00
|
|
|
bool canAuthenticate;
|
2020-09-10 17:51:59 +03:00
|
|
|
try {
|
2024-04-18 10:00:24 -07:00
|
|
|
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
|
|
|
|
} catch (error) {
|
|
|
|
print("Exception checking support. $error");
|
|
|
|
canAuthenticate = false;
|
2020-09-10 17:51:59 +03:00
|
|
|
}
|
|
|
|
|
2024-04-18 10:00:24 -07:00
|
|
|
return canAuthenticate;
|
2020-09-10 17:51:59 +03:00
|
|
|
}
|
|
|
|
}
|