Application lifecycle
Domains:
Flutter
How do I listen to application lifecycle events?
In Xamarin.Forms, you have an Application
that contains OnStart
, OnResume
and OnSleep
. In Flutter you can instead listen to similar lifecycle events by hooking into the WidgetsBinding
observer and listening to the didChangeAppLifecycleState()
change event.
The observable lifecycle events are:
- inactive
- The application is in an inactive state and is not receiving user input. This event is iOS only.
- paused
- The application is not currently visible to the user, is not responding to user input, but is running in the background.
- resumed
- The application is visible and responding to user input.
- suspending
- The application is suspended momentarily. This event is Android only.
For more details on the meaning of these states, see the AppLifecycleStatus
documentation.