didChangeAppLifecycleState method
Called when the system puts the app in the background or returns the app to the foreground.
Implementation
@protected
@override
@mustCallSuper
void didChangeAppLifecycleState(AppLifecycleState state) {
/// No 'setState()' functions are allowed to fully function at this point.
_rebuildAllowed = false;
/// First, process the State object's own event functions.
switch (state) {
case AppLifecycleState.inactive:
inactiveLifecycleState();
break;
case AppLifecycleState.paused:
pausedLifecycleState();
break;
case AppLifecycleState.detached:
detachedLifecycleState();
break;
case AppLifecycleState.resumed:
resumedLifecycleState();
break;
}
for (final listener in _beforeList) {
listener.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.inactive:
listener.inactiveLifecycleState();
break;
case AppLifecycleState.paused:
listener.pausedLifecycleState();
break;
case AppLifecycleState.detached:
listener.detachedLifecycleState();
break;
case AppLifecycleState.resumed:
listener.resumedLifecycleState();
break;
}
}
for (final con in _controllerList) {
con.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.inactive:
con.inactiveLifecycleState();
break;
case AppLifecycleState.paused:
con.pausedLifecycleState();
break;
case AppLifecycleState.detached:
con.detachedLifecycleState();
break;
case AppLifecycleState.resumed:
con.resumedLifecycleState();
break;
}
}
for (final listener in _afterList) {
listener.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.inactive:
listener.inactiveLifecycleState();
break;
case AppLifecycleState.paused:
listener.pausedLifecycleState();
break;
case AppLifecycleState.detached:
listener.detachedLifecycleState();
break;
case AppLifecycleState.resumed:
listener.resumedLifecycleState();
break;
}
}
_rebuildAllowed = true;
if (_rebuildRequested || _inTester) {
_rebuildRequested = false;
/// Perform a 'rebuild' if requested.
refresh();
}
}