authenticateUser method

Future<bool> authenticateUser(
  1. Function fallback
)

Implementation

Future<bool> authenticateUser(Function fallback) async {
  bool isAuthenticated = false;
  List<BiometricType> biometricTypes =
      await _localAuthentication.getAvailableBiometrics();

  if (isBiometricSupported) {
    try {
      isAuthenticated = await _localAuthentication.authenticate(
          localizedReason: 'Please complete the biometrics',
          options: const AuthenticationOptions(
            biometricOnly: true,
            useErrorDialogs: true,
            stickyAuth: true,
          ));
    } on PlatformException catch (_) {
      fallback();
    }
  }

  return isAuthenticated;
}