is_lock_screen2
2.1.0, released 5 months ago by an unverified publisher
Detects whether an Android or iOS device is currently in the lock screen state.
What it does
Provides a method to check if the device is locked using platform-specific APIs on Android and a heuristic combining protected data and screen brightness on iOS. It helps determine whether the app entered the background because the user locked the screen or left the app.
AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to know if the app went to the background because the user locked the device screen.
- You want to handle app lifecycle changes differently depending on whether the device is locked.
Skip it when
- You require a bulletproof, 100% reliable security source of truth on iOS, as iOS detection relies on a heuristic.
- You are running tests on an iOS simulator, since it only works on physical devices for iOS.
Strengths
- Distinguishes between app minimization and screen locking.
- Provides both a nullable API and a throwing API for handling errors.
- Uses safe native APIs instead of private APIs that violate App Store guidelines.
Weaknesses
- iOS implementation is purely heuristic and does not use a stable public lock-screen API.
- Does not work on iOS simulators (physical device required).
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Not documented
bool? result = await isLockScreen();Alternatives
Packages that do the same job and could replace is_lock_screen2.
- is_lock_screen
Detects if a device is currently in the lock screen.
50Compare - wakelock_plus
Keep the device screen awake across mobile, desktop, and web platforms.
92Compare - flutter_overlay_window
Flutter plugin to display your app over other apps on the screen.
85Compare - corner_radius_plugin
Flutter plugin to read device screen corner radii on Android and iOS
69Compare