wakelock 0.1.2 wakelock: ^0.1.2 copied to clipboard
This Flutter plugin allows you to keep Android and iOS devices awake, i.e. prevent them from sleeping by toggling the wakelock of the phone or tablet on or off.
This plugin allows you to enable and toggle the Android and iOS screen wakelock, which prevents the screen from turning off automatically.
Essentially, this allows you to keep the device awake, i.e. prevent the phone or tablet from sleeping.
To use this plugin, follow the installing guide.
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 on = true; // The following statement enables the wakelock. Wakelock.toggle(on: on); on = false; // The following statement disables the wakelock. Wakelock.toggle(on: on); // If you want to retrieve the current wakelock status, // you will have to be in an async scope // to await the Future returned by isEnabled. bool isEnabled = await Wakelock.isEnabled;
If you want to wait for the wakelock toggle on Android or iOS to complete (which takes an insignificant amount of time), you can also await either of
This plugin is originally based on
Specifically, the wakelock functionality was extracted into this plugin due to a lack of maintenance.