Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keep screen active with Flutter

Tags:

flutter

dart

There is a part of my app, where the user will go to a text screen, and while the user is on that page, I want the device screen not to turn off, but to keep it on, and if the user leaves this page, this function be deactivated. How can I do this with flutter?

like image 786
Nata Cordeiro Avatar asked Oct 23 '25 10:10

Nata Cordeiro


1 Answers

Option A: Use a package

I would use a package for what you are trying to accomplish such as:

  • Wakelock: https://pub.dev/packages/wakelock

Option B: Write platform specific code

If you don't want to use a package, you should investigate how this functionality can be implemented on Android and iOS in native code. Such as:

  • Android: How do I prevent an Android device from going to sleep programmatically?
  • iOS: How to disable/enable the sleep mode programmatically in iOS?

Then you should refer to the Flutter documentation for writing code towards specific platforms and integrate it into your codebase: https://docs.flutter.dev/development/platform-integration/platform-channels

like image 181
Tor-Martin Holen Avatar answered Oct 25 '25 00:10

Tor-Martin Holen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!