didChangeAppLifecycleState method
- AppLifecycleState state
override
Observes Flutter's app lifecycle to manage battery consumption.
It automatically stops periodic checks when the app goes into the background and resumes them when the app returns to the foreground.
Implementation
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused ||
state == AppLifecycleState.inactive) {
_stopPeriodicChecks();
} else if (state == AppLifecycleState.resumed) {
_startPeriodicChecks();
}
}