didChangeAppLifecycleState method

  1. @override
void didChangeAppLifecycleState(
  1. AppLifecycleState state
)
override

Called when the system puts the app in the background or returns the app to the foreground.

Implements the WidgetsBindingObserver.

Implementation

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  debug('$runtimeType - App lifecycle state changed: $state');
  switch (state) {
    case AppLifecycleState.inactive:
    case AppLifecycleState.hidden:
      break;
    case AppLifecycleState.paused:
    case AppLifecycleState.detached:
      deactivate();
      break;
    case AppLifecycleState.resumed:
      activate();
      break;
  }
}