Konstantin
Konstantin

Reputation: 1310

Is there a wakelock in flutter?

I'm using Flutter dev version 1.7.8 is there a way to keep screen always on? I've been googling a lot on this and this is the only thing I've found How to keep application awake in flutter? But this plugin doesn't work anymore. The last release was almost a year ago, I suppose there were some breaking changes in flutter during this time

It's not an option for me to write my own plugin for it right now

Upvotes: 2

Views: 2585

Answers (1)

creativecreatorormaybenot
creativecreatorormaybenot

Reputation: 126904

Alternative

Full disclosure: Due to issues I was having with the screen plugin, I created a plugin (wakelock) for wakelock exclusively. More on that here.

Fixing screen

The plugin you mentioned, i.e. screen does still work. You will just have to migrate it to AndroidX in Android Studio when running on Android (open the android module in Android Studio and use Refactor -> Migrate to AndroidX).

There are a few open pull requests.
An alternative to manually migrating to AndroidX would be making use of one of the pull requests and using a git dependency in your pubspec.yaml instead:

dependencies:
  screen:
    git:
      url: https://github.com/clovisnicolas/flutter_screen
      ref: 496b60ac1acbc3d5e8400bb2032c5c9d7e46d4c7

If you still cannot get it to work, let me know and I might publish a fixed version of this plugin or a wake lock only plugin.

Upvotes: 4

Related Questions