Skip to content

A Flutter plugin to programmatically turn the screen off or on using the proximity sensor. This is especially useful for custom calling apps or scenarios where the screen needs to be turned off when the device is close to the user.

License

Notifications You must be signed in to change notification settings

Musaddiq625/screen_off

Repository files navigation

screen_off

A Flutter plugin to programmatically turn the screen off or on using the proximity sensor. This is especially useful for custom calling apps or scenarios where the screen needs to be turned off when the device is close to the user.

Features

  • 📴 Turn screen off using proximity sensor
  • ⚡ Turn screen back on when the sensor is no longer triggered
  • 🔌 Easy to integrate into any Flutter app
  • ✅ Works on both Android and iOS

Usage

Android

Add the following permission to your AndroidManifest.xml if needed:

<uses-permission android:name="android.permission.WAKE_LOCK"/>

iOS

No additional setup is required for iOS. Just make sure the app has permission to access the proximity sensor (enabled by default).

Flutter

import 'package:screen_off/screen_off.dart';

/// Turn screen off
await ScreenOff.turnScreenOff();

/// Turn screen on
await ScreenOff.turnScreenOn();

Platform

Platform Support
Android
iOS

Installation

Add this to your pubspec.yaml:

dependencies:
  screen_off: <latest_version>

Then run:

flutter pub get

If you find it useful, a ⭐ on GitHub is appreciated.

Maintainer

Developed and maintained by Musaddiq625

Contributing

🤔 Something broken? Got a better way to do it?
Don’t be shy - I’d love your contribution. Every PR will make this project stronger! 💪🏻

License

This project is licensed under the MIT License - see the LICENSE file for details.


🩵 Sponsors

Show your appreciation to our sponsors:

About

A Flutter plugin to programmatically turn the screen off or on using the proximity sensor. This is especially useful for custom calling apps or scenarios where the screen needs to be turned off when the device is close to the user.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published