screen_lock_detector
2.0.0, released 5 months ago by mrrhak.com
Detect screen lock and unlock events across Android and iOS platforms.
What it does
A Flutter plugin that enables your app to detect screen lock and unlock events across Android and iOS platforms. It provides native event callbacks and an event stream, as well as a way to perform manual status checks.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to pause sensitive activities when the screen locks.
- You want to log out users or trigger background operations upon device lock/unlock.
- You are building a mobile application for Android and iOS.
Skip it when
- You need to test on simulators or emulators, as native system events are not available there.
- You are targeting web, desktop, or other non-mobile platforms.
Strengths
- Supports both event streams and manual status checks.
- Native event callbacks for both Android and iOS.
Weaknesses
- Does not work on simulators or emulators due to reliance on native system events.
- Limited platform support (only Android and iOS).
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add the dependency to pubspec.yaml. Test on physical devices as it does not function on simulators or emulators.
ScreenLockDetector.statusStream.listen((status) {
print("Screen status: $status");
if (status == ScreenStatus.locked) {
} else if (status == ScreenStatus.unlocked) {
}
});Alternatives
Packages that do the same job and could replace screen_lock_detector.
- 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 - flutter_screen_wake
Manage device screen wake state and brightness on Android and iOS.
40Compare
Works with
Packages commonly used together with screen_lock_detector: ones it builds on, ones built on it, and its own family.