toggle static method

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.
WakelockPlus.toggle(enable: true);

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

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

Implementation

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