UnlockDetector class
Detects device and app presence state.
Static API — call initialize once, listen to stream, call dispose when finished:
await UnlockDetector.initialize();
final sub = UnlockDetector.stream.listen((status) {
if (status.isOnline) { /* user active */ }
});
// ...
await sub.cancel();
await UnlockDetector.dispose();
Constructors
- UnlockDetector()
-
Const constructor — this class only exposes static members.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- currentStatus → UnlockDetectorStatus?
-
The most recently observed status, or
nullbefore the first event (or after dispose).no setter - isAndroid → bool
-
Whether the current platform is Android.
no setter
- isInitialized → bool
-
Whether initialize has been called.
no setter
- isIOS → bool
-
Whether the current platform is iOS.
no setter
-
stream
→ Stream<
UnlockDetectorStatus> -
Broadcast stream of presence changes. Call initialize before listening.
no setter
Static Methods
-
activityDetector(
{required Widget child}) → Widget -
Wraps
childso any pointer interaction calls reportActivity. -
dispose(
) → Future< void> - Stops detection and releases resources. Safe to call multiple times.
-
getPlatformInfo(
) → String - A human-readable description of detection behavior on this platform.
-
initialize(
{Duration? idleTimeout}) → Future< void> - Starts detection. Safe to call multiple times — initializes only once.
-
isDeviceLocked(
) → Future< bool> - Whether the device is currently locked.
-
reportActivity(
) → void - Reports user interaction, resetting the idle timer.