screen_state
5.0.2, released 4 months ago by cachet.dk
Tracks screen state events on Android and iOS.
What it does
A Flutter plugin that reports screen events such as screen on, screen off, and unlocks while the application is running. It provides a stream of ScreenStateEvent objects to listen for state changes.
AI-written summary of version 5.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to track screen on and off events in your application.
- You need to detect screen unlocks on supported Android and iOS devices.
Skip it when
- You are running your app inside the iOS simulator where detection does not function.
- Your application targets platforms other than Android and iOS.
Strengths
- Provides a simple stream-based API for screen events.
- Supports both Android and iOS platforms.
Weaknesses
- iOS detection has specific limitations such as requiring passcodes for unlock events and not working in the simulator.
- Low brightness settings on iOS may erroneously generate screen on events.
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Requires adding screen_state as a dependency in pubspec.yaml. Android requires minSdk 24 and iOS requires iOS 15.0.
Screen _screen;
StreamSubscription<ScreenStateEvent> _subscription;
void onData(ScreenStateEvent event) {
print(event);
}
void startListening() {
_screen = new Screen();
try {
_subscription = _screen.screenStateStream.listen(onData);
} on ScreenStateException catch (exception) {
print(exception);
}
}Alternatives
Packages that do the same job and could replace screen_state.
- workmanager
Schedule background work and execute Dart code on Android, iOS, macOS, Web, and Linux.
79Compare - flutter_overlay_window
Flutter plugin to display your app over other apps on the screen.
85Compare - android_alarm_manager_plus
Access Android AlarmManager service and run Dart code in the background.
89Compare - screen_capture_event
Catch screenshots and screen recordings on Android and iOS.
87Compare
Works with
Packages commonly used together with screen_state: ones it builds on, ones built on it, and its own family.