wakelock 0.5.6 wakelock: ^0.5.6 copied to clipboard
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping
The plugin allows you to enable and toggle the screen wakelock, which prevents the screen from turning off automatically.
Essentially, this allows you to keep the device awake, i.e. prevent the device from sleeping.
Supported platforms #
To use this plugin, follow the installing guide.
wakelock plugin does not require any special permissions on any platform :)
This is because it only enables the screen wakelock and not any partial (CPU) wakelocks that would keep the app alive in the background.
Everything in this plugin is controlled via the
If you want to enable the wakelock, i.e. keep the device awake, you can simply call
and to disable it again, you can use
import 'package:wakelock/wakelock.dart'; // ... // The following line will enable the Android and iOS wakelock. Wakelock.enable(); // The next line disables the wakelock again. Wakelock.disable();
import 'package:wakelock/wakelock.dart'; // ... // The following lines of code toggle the wakelock based on a bool value. bool enable = true; // The following statement enables the wakelock. Wakelock.toggle(enable: enable); enable = false; // The following statement disables the wakelock. Wakelock.toggle(enable: enable); // If you want to retrieve the current wakelock status, // you will have to be in an async scope // to await the Future returned by `enabled`. bool wakelockEnabled = await Wakelock.enabled;
If you want to wait for the wakelock toggle to complete (which takes an insignificant amount of
time), you can also
await any of
Learn more #
If you want to learn more about how this plugin works, how to contribute, etc., you can read through the main README on GitHub.