authenticate method

Future<bool> authenticate()

Implementation

Future<bool> authenticate() async {
  bool isBiometricSupported = await auth.canCheckBiometrics &&
                             await auth.isDeviceSupported();
  if (!isBiometricSupported) {
    // Handle the case where biometrics are not supported
    return false;
  }

  try {
    return await auth.authenticate(
      localizedReason: 'Authenticate to access secure storage',
      options: const AuthenticationOptions(biometricOnly: true),
    );
  } catch (e) {
    // Handle authentication errors or user cancellation
    return false;
  }
}