AppLifecycleState enum

States that an application can be in once it is running.

States not supported on a platform will be synthesized by the framework when transitioning between states which are supported, so that all implementations share the same state machine.

The initial value for the state is the detached state, updated to the current state (usually resumed) as soon as the first lifecycle update is received from the platform.

For historical and name collision reasons, Flutter's application state names do not correspond one to one with the state names on all platforms. On Android, for instance, when the OS calls Activity.onPause, Flutter will enter the inactive state, but when Android calls Activity.onStop, Flutter enters the paused state. See the individual state's documentation for descriptions of what they mean on each platform.

The current application state can be obtained from SchedulerBinding.instance.lifecycleState, and changes to the state can be observed by creating an AppLifecycleListener, or by using a WidgetsBindingObserver by overriding the WidgetsBindingObserver.didChangeAppLifecycleState method.

Applications should not rely on always receiving all possible notifications.

For example, if the application is killed with a task manager, a kill signal, the user pulls the power from the device, or there is a rapid unscheduled disassembly of the device, no notification will be sent before the application is suddenly terminated, and some states may be skipped.

See also:

Inheritance
Available extensions

Values

detached → const AppLifecycleState

The application is still hosted by a Flutter engine but is detached from any host views.

The application defaults to this state before it initializes, and can be in this state (applicable on Android, iOS, and web) after all views have been detached.

When the application is in this state, the engine is running without a view.

This state is only entered on iOS, Android, and web, although on all platforms it is the default state before the application begins running.

resumed → const AppLifecycleState

On all platforms, this state indicates that the application is in the default running mode for a running application that has input focus and is visible.

On Android, this state corresponds to the Flutter host view having focus (Activity.onWindowFocusChanged was called with true) while in Android's "resumed" state. It is possible for the Flutter app to be in the inactive state while still being in Android's "onResume" state if the app has lost focus (Activity.onWindowFocusChanged was called with false), but hasn't had Activity.onPause called on it.

On iOS and macOS, this corresponds to the app running in the foreground active state.

inactive → const AppLifecycleState

At least one view of the application is visible, but none have input focus. The application is otherwise running normally.

On non-web desktop platforms, this corresponds to an application that is not in the foreground, but still has visible windows.

On the web, this corresponds to an application that is running in a window or tab that does not have input focus.

On iOS and macOS, this state corresponds to the Flutter host view running in the foreground inactive state. Apps transition to this state when in a phone call, when responding to a TouchID request, when entering the app switcher or the control center, or when the UIViewController hosting the Flutter app is transitioning.

On Android, this corresponds to the Flutter host view running in Android's paused state (i.e. Activity.onPause has been called), or in Android's "resumed" state (i.e. Activity.onResume has been called) but does not have window focus. Examples of when apps transition to this state include when the app is partially obscured or another activity is focused, a app running in a split screen that isn't the current app, an app interrupted by a phone call, a picture-in-picture app, a system dialog, another view. It will also be inactive when the notification window shade is down, or the application switcher is visible.

On Android and iOS, apps in this state should assume that they may be hidden and paused at any time.

hidden → const AppLifecycleState

All views of an application are hidden, either because the application is about to be paused (on iOS and Android), or because it has been minimized or placed on a desktop that is no longer visible (on non-web desktop), or is running in a window or tab that is no longer visible (on the web).

On iOS and Android, in order to keep the state machine the same on all platforms, a transition to this state is synthesized before the paused state is entered when coming from inactive, and before the inactive state is entered when coming from paused. This allows cross-platform implementations that want to know when an app is conceptually "hidden" to only write one handler.

paused → const AppLifecycleState

The application is not currently visible to the user, and not responding to user input.

When the application is in this state, the engine will not call the PlatformDispatcher.onBeginFrame and PlatformDispatcher.onDrawFrame callbacks.

This state is only entered on iOS and Android.

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<AppLifecycleState>
A constant List of the values in this enum, in order of their declaration.