Skip to content Skip to sidebar Skip to footer

How To Handle Onpause/onresume In Flutter App?

I'm new to Dart/Flutter and would like to build a simple app where a LinearProgressBar gets updated every second. Without getting too much into the actual code, I have the followin

Solution 1:

You can override the didChangeAppLifecycleState of the WidgetBindingObserver interface to receive notifications for app lifecycle changes.

There's sample code in this page

Solution 2:

You can use lifecycle channel from SystemChannels.

Example:

SystemChannels.lifecycle.setMessageHandler((msg){
  debugPrint('SystemChannels> $msg');
});

Output:

I/flutter ( 3672): SystemChannels> AppLifecycleState.paused
I/flutter ( 3672): SystemChannels> AppLifecycleState.resumed

Post a Comment for "How To Handle Onpause/onresume In Flutter App?"