Manage App Lifecycle in Flutter!

Image copyright to the respective owner
  • detached:
    The application is still hosted on a flutter engine but is detached from any host views. This means that the app or the engine is initializing while the view is not yet available for the user to interact with.
  • inactive:
    The application is in an inactive state and is not receiving user input. This means that the app is still in the foreground but the user is not interacting with your app. Usually, this state is encountered when the app is open and the user is in a phone call, responding to a TouchID request, opens notification panel, system dialog, picture-in-picture window, etc.
  • paused:
    This state is encountered when the application is not currently visible to the user, not responding to user input, and running in the background.
  • resumed:
    This state is encountered when the application is again in the foreground and is visible and responding to user input.

Step1: Add WidgetsBindingObserver to your class and add the observer.

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('State: $state');
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('State: $state');
if (state == AppLifecycleState.resumed) print('App Resumed');
}

Don’t forget to connect with me on:

Don’t stop, until you are breathing!💙
- Abhishek Doshi

--

--

--

Google Developer Expert — Dart, Flutter & Firebase 💙💛

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Periodic Table of Software Testing Tools…✍🧮💁‍♀️👇

Go(Lang) without a PATH

Getting Started with Git

Installing Percona XtraDB 5.7 Cluster on Centos 7 — UKHost4U

Checkout Field Editor Pro WooCommerce

Inference in Graph Database

Updating Manjaro Linux on my HP ProBook 450 G4

Python Fast API and Graph Database integration

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Doshi

Abhishek Doshi

Google Developer Expert — Dart, Flutter & Firebase 💙💛

More from Medium

Integrating Flutterwave with a Flutter App.

Top Flutter App Development Companies Of 2022

Introduction To Flutter

Divider in Flutter