unlock method

Future<SecurityResult<bool>> unlock({
  1. String? reason,
})

Shows the biometric prompt and unlocks on success.

  • Success(true) – unlocked (also when it was not locked at all).
  • Success(false) – the user cancelled; still locked.
  • Failure – biometrics unavailable / locked out / error; still locked. Use forceUnlock after your own fallback authentication.

Concurrent calls share one prompt.

Implementation

Future<SecurityResult<bool>> unlock({String? reason}) {
  if (!_locked) return Future.value(const Success(true));
  final running = _unlocking;
  if (running != null) return running;

  final future = _authenticate(reason);
  _unlocking = future;
  future.whenComplete(() {
    if (identical(_unlocking, future)) _unlocking = null;
  });
  return future;
}