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?
Asked
Active
Viewed 1,702 times
1 Answers
1
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

Tor-Martin Holen
- 1,359
- 1
- 13
- 19
-
1thank you very much, for the examples I saw in the Flutter package, it will solve my problem! :D – Nata Cordeiro Apr 07 '22 at 22:57