authenticate method

  1. @override
Future<SecureAuthResult> authenticate({
  1. required String reason,
  2. bool biometricOnly = false,
})
override

Implementation

@override
Future<SecureAuthResult> authenticate({
  required String reason,
  bool biometricOnly = false,
}) async {
  try {
    final result = await methodChannel.invokeMethod<String>('authenticate', {
      'reason': reason,
      'biometricOnly': biometricOnly,
    });
    if (result == null) {
      return SecureAuthResult.error;
    }
    switch (result) {
      case 'success':
        return SecureAuthResult.success;
      case 'canceled':
        return SecureAuthResult.canceled;
      case 'notAvailable':
        return SecureAuthResult.notAvailable;
      case 'passcodeNotSet':
        return SecureAuthResult.passcodeNotSet;
      default:
        return SecureAuthResult.error;
    }
  } on PlatformException catch (_) {
    return SecureAuthResult.error;
  }
}