Skip to content
pubscout

screen_lock_detector

2.0.0, released 5 months ago by mrrhak.com

Detect screen lock and unlock events across Android and iOS platforms.

WASM-ready
$ flutter pub add screen_lock_detector
Source repository

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.

Works with

Packages commonly used together with screen_lock_detector: ones it builds on, ones built on it, and its own family.