didChangeAppLifecycleState method
Called when the system puts the app in the background or returns the app to the foreground.
Implementation
@override
@mustCallSuper
void didChangeAppLifecycleState(AppLifecycleState state) {
/// No 'setState()' functions are allowed to fully function at this point.
// _setStateAllowed = false;
/// First, process the State object's own event functions.
switch (state) {
case AppLifecycleState.inactive:
_inactiveAppLifecycle = true;
_didChangeAppLifecycleStateXControllers(state);
inactiveAppLifecycleState();
_hiddenAppLifecycle = false;
break;
case AppLifecycleState.hidden:
_hiddenAppLifecycle = true;
_didChangeAppLifecycleStateXControllers(state);
hiddenAppLifecycleState();
_pausedAppLifecycle = false;
break;
case AppLifecycleState.paused:
_pausedAppLifecycle = true;
_didChangeAppLifecycleStateXControllers(state);
pausedAppLifecycleState();
_detachedAppLifecycle = false;
_resumedAppLifecycle = false;
break;
case AppLifecycleState.detached:
_detachedAppLifecycle = true;
_didChangeAppLifecycleStateXControllers(state);
detachedAppLifecycleState();
break;
case AppLifecycleState.resumed:
_resumedAppLifecycle = true;
_didChangeAppLifecycleStateXControllers(state);
resumedAppLifecycleState();
_inactiveAppLifecycle = false;
break;
default:
// WARNING: Missing case clause
}
_setStateAllowed = true;
if (_setStateRequested) {
_setStateRequested = false;
// Only the latest State is rebuilt
if (isLastState) {
/// Perform a 'rebuild' if requested.
setState(() {});
}
}
// Record the triggered event
assert(() {
if (_printEvents) {
//ignore: avoid_print
print(
'============ Event: didChangeAppLifecycleState($state) in $this');
}
return true;
}());
}