toggle static method Null safety

Future<void> toggle(
  1. {required bool enable}

Toggles the wakelock on or off.

You can simply use this function to toggle the wakelock using a bool value (for the enable parameter).

// This line keeps the screen on.
Wakelock.toggle(enable: true);

bool enableWakelock = false;
// The following line disables the wakelock.
Wakelock.toggle(enable: enableWakelock);

You can await the Future to wait for the operation to complete.


static Future<void> toggle({
  required bool enable,
}) {
  return wakelockPlatformInstance.toggle(enable: enable);