-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Our company is making an app with the requirement that whenever it's running in the foreground, the screen should never turn off.
So far, we've been calling WakeLockPlus.enable() in main(), but we saw a note on the plugin's page that says, "The wakelock can be released by external sources at any time (e.g., by the OS). Only calling WakelockPlus.enable() once will most likely mean that the screen turns off at one point or another anyway."
So, in our case, what's the solution for our app to keep the screen from turning off? We currently have two possible solutions:
1 Using Flutter lifecycle in "MyApp" class, so whenever the app is resumed, we enable to WakeLockPlus again, like this:
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
// Perform actions when the app is resumed
Wakelockplus.enable();
// e.g., refresh data, re-authenticate, etc.
}
}2 Using Timer, periodically call Wakelockplus.enable()
Thank you.