onAppLifecycleStateChanged method

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

Implementation

@override
void onAppLifecycleStateChanged(AppLifecycleState state) {
  if (state == AppLifecycleState.paused || state == AppLifecycleState.inactive) {
    // When app goes to background, fetch and update cache but DON'T fire events
    unawaited(_refreshIfStale());
  } else if (state == AppLifecycleState.resumed) {
    // When app comes to foreground, only fire events if enabled and we have pending updates
    if (isArtifactRefreshEnabled() && _hasPendingUpdate) {
      unawaited(_handlePendingUpdate());
    }
  }
}