didChangeAppLifecycleState method

void didChangeAppLifecycleState (
  1. AppLifecycleState state
)
override

Respond to changes in the app lifecycle state, on iOS

Restart timer if resumed; else cancel it

Implementation

void didChangeAppLifecycleState(AppLifecycleState state) {
  if (state == AppLifecycleState.resumed) {
    if (Platform.isIOS) _refreshTimer ??= Timer.periodic(_refreshPeriod, _refresh);
    _refresh();
  } else {
    _refreshTimer?.cancel();
    _refreshTimer = null;
    this.track = NowPlayingTrack.notPlaying;
  }
}