| 1 | import 'package:cw_core/utils/print_verbose.dart'; |
| 2 | import 'package:flutter/services.dart'; |
| 3 | import 'package:flutter_local_authentication/flutter_local_authentication.dart'; |
| 4 | |
| 5 | class BiometricAuth { |
| 6 | final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication(); |
| 7 | |
| 8 | Future<bool> isAuthenticated() async { |
| 9 | try { |
| 10 | final authenticated = await _flutterLocalAuthenticationPlugin.authenticate(); |
| 11 | return authenticated; |
| 12 | } catch (e) { |
| 13 | printV(e); |
| 14 | } |
| 15 | return false; |
| 16 | } |
| 17 | |
| 18 | Future<bool> canCheckBiometrics() async { |
| 19 | bool canAuthenticate; |
| 20 | try { |
| 21 | canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate(); |
| 22 | await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(0); |
| 23 | } catch (error) { |
| 24 | printV("Exception checking support. $error"); |
| 25 | canAuthenticate = false; |
| 26 | } |
| 27 | |
| 28 | return canAuthenticate; |
| 29 | } |
| 30 | } |