AppLifecycleMixin class mixin
A mixin class that simplifies observing Flutter application lifecycle events, system updates, and navigation callbacks.
This acts as a wrapper around WidgetsBindingObserver, allowing classes to react to lifecycle changes without having to manually register or implement all observer methods.
Subclasses can mix in or extend this class and override only the specific callbacks they require.
Example
class HomeController extends MinNotifier with AppLifecycleMixin {
@override
void onResumed() {
debugPrint('App returned to the foreground');
}
@override
void onPaused() {
debugPrint('App went to the background');
}
}
- Implemented types
Constructors
- AppLifecycleMixin()
-
Creates a new instance of AppLifecycleMixin to observe
Flutter's application lifecycle states.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
didChangeAccessibilityFeatures(
) → void -
Called when the system changes the set of currently active accessibility
features.
override
-
didChangeAppLifecycleState(
AppLifecycleState state) → void -
Called when the system puts the app in the background or returns
the app to the foreground.
override
-
didChangeLocales(
List< Locale> ? locales) → void -
Called when the system tells the app that the user's locale has
changed. For example, if the user changes the system language
settings.
override
-
didChangeMetrics(
) → void -
Called when the application's dimensions change. For example,
when a phone is rotated.
override
-
didChangePlatformBrightness(
) → void -
Called when the platform brightness changes.
override
-
didChangeTextScaleFactor(
) → void -
Called when the platform's text scale factor changes.
override
-
didChangeViewFocus(
ViewFocusEvent event) → void -
Called whenever the PlatformDispatcher receives a notification that the
focus state on a view has changed.
override
-
didHaveMemoryPressure(
) → void -
Called when the system is running low on memory.
override
-
didPopRoute(
) → Future< bool> -
Called when the system tells the app to pop the current route, such as
after a system back button press or back gesture.
override
-
didPushRoute(
String route) → Future< bool> -
Called when the host tells the application to push a new route onto the
navigator.
override
-
didPushRouteInformation(
RouteInformation routeInformation) → Future< bool> -
Called when the host tells the application to push a new
RouteInformation and a restoration state onto the router.
override
-
didRequestAppExit(
) → Future< AppExitResponse> -
Called when a request is received from the system to exit the application.
override
-
handleCancelBackGesture(
) → void -
Called when a predictive back gesture is canceled, indicating that no
navigation should occur.
override
-
handleCommitBackGesture(
) → void -
Called when a predictive back gesture is finished successfully, indicating
that the current route should be popped.
override
-
handleStartBackGesture(
PredictiveBackEvent event) → bool -
Called at the start of a predictive back gesture.
override
-
handleStatusBarTap(
) → void -
Called when the user taps the status bar on iOS, to scroll a scroll
view to the top.
override
-
handleUpdateBackGestureProgress(
PredictiveBackEvent event) → void -
Called when a predictive back gesture moves.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAccessibilityFeaturesChanged(
) → void - Called when the active accessibility features of the platform are changed.
-
onCancelBackGesture(
) → void - Called when the predictive back gesture is canceled.
-
onChangeTextScaleFactor(
) → void - Called when the platform's text scale factor changes (e.g., user changes font size settings).
-
onCommitBackGesture(
) → void - Called when the predictive back gesture is fully committed (user completed the swipe).
-
onDetached(
) → void - Called when the application is still hosted on a Flutter engine but is detached from any host views.
-
onHandleStatusBarTap(
) → void - Called when the user taps the device status bar (primarily on iOS devices).
-
onHidden(
) → void - Called when all views of the application have been hidden.
-
onInactive(
) → void - Called when the application is in an inactive state and is not receiving input.
-
onLifecycleChanged(
AppLifecycleState state) → void - Called whenever the application's lifecycle state changes.
-
onLocalesChanged(
List< Locale> ? locales) → void - Called when the system's preferred locales are updated.
-
onMemoryPressure(
) → void - Called when the system is running low on available memory.
-
onMetricsChanged(
) → void - Called when the application's physical metrics (like screen size or orientation) change.
-
onPaused(
) → void - Called when the application is not currently visible to the user and is running in the background.
-
onPlatformBrightnessChanged(
) → void - Called when the platform's active brightness setting changes (e.g., toggling dark mode).
-
onPopRoute(
) → Future< bool> - Called when the system requests to pop the current route.
-
onPushRoute(
String route) → Future< bool> - Called when the system requests to push a new route path.
-
onPushRouteInformation(
RouteInformation routeInformation) → Future< bool> - Called when the system pushes new route information (e.g., via deep linking).
-
onRequestAppExit(
) → Future< AppExitResponse> - Called when the platform requests to terminate the application.
-
onResumed(
) → void - Called when the application is visible and responding to user input.
-
onStartBackGesture(
PredictiveBackEvent event) → bool - Called when a predictive back gesture is initiated.
-
onUpdateBackGestureProgress(
PredictiveBackEvent event) → void - Called sequentially as the predictive back gesture updates its progress.
-
onViewFocusChanged(
ViewFocusEvent event) → void - Called when a view's focus state transitions.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited