Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/entities/authenticator_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {

/// When the app is [paused], it first goes to [inactive] before continuing to [resumed]
/// Ensure that the paused timestamp is not saved just before the app becomes [resumed]
if (_lastState != AppLifecycleState.paused) {
if (_lastState != AppLifecycleState.paused &&
_lockController.lockState is Unlocked) {
_repository.savePausedTimestamp(DateTime.now());
}
break;
Expand Down
9 changes: 7 additions & 2 deletions lib/src/entities/lock_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class LockController {
/// state of the app
late final Stream<LockState> state;

// The current lock state of the app
late LockState lockState = const Unlocked();

/// Optionally register a callback that gets triggered every time the app is locked
/// (e.g., for analytics purposes)
final VoidCallback? onLockCallback;
Expand All @@ -36,13 +39,15 @@ class LockController {
/// [availableMethods] refer to [BiometricMethod]s that the device supports, or an empty list if the
/// device doesn't support biometrics or the user has not opted in to using it.
void lock({required List<BiometricMethod> availableMethods}) {
_streamController.add(Locked(availableBiometricMethods: availableMethods));
lockState = Locked(availableBiometricMethods: availableMethods);
_streamController.add(lockState);
}

/// Results in dismissing the lock screen overlay and making the app contents visible.
/// Probably shouldn't be used manually, unless there's a really good reason to. It was
/// intended to be used by the pin_lock package internally
void unlock() {
_streamController.add(const Unlocked());
lockState = const Unlocked();
_streamController.add(lockState);
}
}