fluttercommunity / wakelock_plus

Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
BSD 3-Clause "New" or "Revised" License
71 stars 54 forks source link

Uncaught Web Exception #38

Open corepuncher opened 7 months ago

corepuncher commented 7 months ago

For web build (in debug) I encountered the following uncaught exception:

NotAllowedError, Failed to execute 'request' on 'WakeLock': The requesting page is not visible

In the stack, this code gets highlighted:

  @override
  Future<void> toggle({required bool enable}) async {
    // Make sure the JS library is loaded before calling it.
    await _jsLoaded;

    wakelock_plus_web.toggle(enable);
  }
diegotori commented 7 months ago

@corepuncher please clean up the example code with the correct formatting.

Thanks.