Overview
The is_lock_screen package detects whether a device is currently locked, helping apps distinguish between backgrounding due to screen lock and other reasons like app switching. It provides a simple API to check the lock screen state on both Android and iOS platforms. This is particularly useful for apps that need to adjust behavior when the device is locked, such as pausing sensitive operations or managing authentication states. The package integrates seamlessly with Flutter and relies on native platform features for accurate detection.
Use cases
- Detecting if app entered background due to screen lock
- Pausing background tasks when device is locked
- Managing authentication sessions based on lock state
- Improving battery efficiency by adjusting activity in locked state
- Enhancing security by responding to lock events
Key features
- Cross-platform support (Android & iOS)
- Simple boolean check for lock state
- Lightweight and minimal dependencies
- Uses native platform APIs for accuracy
- Easy integration via Flutter pub
Suitable for
- Apps requiring lock state awareness
- Security-sensitive applications
- Background task managers
- Battery optimization tools
- Authentication flow controllers
Considerations
- Requires appropriate permissions on some platforms
- May not detect lock state immediately after unlock
- Limited to detecting lock status, not unlock events
- Depends on OS-level implementation consistency
- Not suitable for high-frequency polling scenarios