unlock_detector 1.4.0
unlock_detector: ^1.4.0 copied to clipboard
A Flutter plugin to detect device lock/unlock and app foreground/background events for user online/offline presence.
CHANGES #
1.4.0 #
Breaking: the minimum supported version is now Flutter 3.44 / Dart 3.12,
and your app must build with Android Gradle Plugin 9 or newer. Stay on 1.3.x
if you cannot move yet.
- Migrated to built-in Kotlin (#5) — the plugin no longer applies the
Kotlin Gradle Plugin. From Flutter 3.47, an app using a plugin that applies
KGP prints a
flutter doctorwarning, and future Flutter versions fail the build outright. Kotlin now comes from AGP's built-in support. - The plugin's
buildscriptblock is gone with it. It pinned its own AGP and Kotlin versions onto the consuming app's build classpath, where the highest version across the build wins — so the plugin could quietly force an AGP upgrade on an app that never asked for one. Both now come from the app. - The example app moves to AGP 9.3.2, Gradle 9.7.1, Kotlin 2.4.10 and
android.builtInKotlin=true. - Note for apps: AGP 9's built-in Kotlin resolves KGP 2.2.10, below Flutter
3.47's 2.2.20 minimum, so the build fails until you declare a newer KGP in
your app's
settings.gradlewithapply false. See the README.
1.3.0 #
Fixed #
- Idle could fire after
dispose()—dispose()now clears the idle timeout, and every status emission is gated on the detector being active, so a latereportActivity()or an in-flight OS idle poll can no longer push a status onto the stream after teardown. - A failed
initialize()leaked its listeners — the lifecycle listener and the native event subscription are now torn down on the error path. Retrying after a failure previously left a second subscription behind, which delivered every native event twice. - Desktop idle polling ran in the background — the OS idle poll now stops when the window loses focus and restarts when it regains focus, instead of waking every few seconds for a status that cannot change.
- Linux: idle detection did not work on Wayland. The X11 screensaver extension only sees XWayland input, so the reported idle time never grew. The compositor is now queried over D-Bus (GNOME/Mutter, and the freedesktop screensaver interface used by KDE), with X11 kept as the source on X11 sessions. The X11 display is also opened once instead of per poll.
- macOS: replaced the deprecated
kIOMasterPortDefaultwithkIOMainPortDefaulton macOS 12+, and readHIDIdleTimethroughNSNumberso a differently-sizedCFNumberno longer silently reports zero idle time. - Android: the event sink is released when the engine detaches, and the
KeyguardManagerlookup uses a checked cast. pubspec.yamldeclaredflutter: ">=3.0.0"but the plugin usesAppLifecycleListenerandAppLifecycleState.hidden; the constraint is now>=3.13.0(Dart>=3.1.0), so an incompatible version fails at resolve time rather than at compile time.
Changed #
- The Android package moved from
com.example.unlock_detectortocom.mustafa707.unlock_detector. Flutter registers the plugin automatically, so no app-side change is needed unless you referenced the class by name.
Added #
- A unit-test suite covering status parsing, the initialize/dispose handshake, event de-duplication, idle behavior, and the teardown fixes above.
- The example app now demonstrates
idleTimeout,activityDetectorandisDeviceLocked, names the real platform it runs on (it previously reported every non-Android platform as iOS), covers theidleandscreenOnstatuses, and follows the light/dark theme instead of hard-coding white.
1.2.0 #
- Native desktop support — macOS, Windows and Linux now ship native plugin
code with system-wide idle detection: when
initialize()is given anidleTimeout, theidlestatus follows the OS idle time (time since any keyboard/mouse input) — noreportActivity()needed on desktop.- macOS: IOKit HID idle time · Windows:
GetLastInputInfo· Linux: the X11 screensaver extension (needslibxss-dev; X11 sessions).
- macOS: IOKit HID idle time · Windows:
- All six platforms are now declared with native implementations in
pubspec.yaml.
1.1.1 #
- Web & desktop: window blur (lost focus) is now reported as
backgroundand window focus asforeground— previously a blurred-but-visible window was missed. Mobile behavior is unchanged.
1.1.0 #
- Web & desktop support — foreground/background and idle now work on web, macOS, Windows and Linux (driven by the Flutter app lifecycle).
- Idle detection — pass
idleTimeouttoinitialize()to receive anidlestatus when the user is inactive; feed interaction viareportActivity()or wrap your app inUnlockDetector.activityDetector(). isDeviceLocked()— one-shot lock-state query (Android reliable viaKeyguardManager, iOS best-effort).currentStatus— read the last status synchronously;initialize()now also emits the current state immediately.- New
screenOnstatus from AndroidACTION_SCREEN_ON. - Add Swift Package Manager support on iOS; CocoaPods still works.
- Foreground/background detection moved to the Flutter app lifecycle (pure Dart) — same events, fewer moving parts, and it works on every platform.
- Android: dropped the unused
RECEIVE_BOOT_COMPLETED,WAKE_LOCKandDISABLE_KEYGUARDpermissions; Kotlin 2.3.21, AGP 8.11.1, Gradle 8.14,compileSdk36. - iOS: deployment target 13.0; added a privacy manifest; observers removed on deinit; fixed podspec metadata.
- Removed the stale Android unit test; added
flutter_lints; shorter README.
1.0.0 #
- detect more state new isOnline , isOffline flags
- upgrade versions
- update
Readmewith new names changes
0.1.0 #
- solve
iOSnot working reported by kmiller issue#1 - make initializing direct when listen to stream
- update
Readmewith new names changes
0.0.6 #
- change calls names
startDetectionit changed toinitialize - change calls names
lockUnlockStreamit changed tostream - update
Readmewith new names changes
0.0.5 #
- update
changelogfile.
0.0.4 #
- make
minAndroidSdkto 19 instead of 21. - Add Enum Named
UnlockDetectorStatusas return value.
0.0.3 #
- update dart version to 3.0.0.
0.0.2 #
- update
readmefile.
0.0.1 #
- release the package.