appStateStream property

Stream<AppState> get appStateStream

Subscribe to this to get notified of changes in AppState.

Call startListening before subscribing to this stream to start listening to background/foreground events on the platform side.

Implementation

static Stream<AppState> get appStateStream =>
    _eventChannel.receiveBroadcastStream().map(
      (event) =>
          event == 'foreground' ? AppState.foreground : AppState.background,
    );