activityUpdateStream property

Stream<ActivityUpdate> get activityUpdateStream

A stream of activity updates. An event is emitted onto this stream each time a pushTokenUpdate occurs. The operating system can decide to update a push token at any time. An update can also mean that the activity has ended or it became stale

You can map out each type of update to respond to it

activityUpdateStream.listen((event) => event.map(
  active: (state) { ... },
  ended: (state) { ... },
  stale: (state) { ... },
  unknown: (state) { ... },
))

or if you only want to react to limited updates you can use mapOrNull

activityUpdateStream.listen((event) => event.mapOrNull(
  active: (state) { ... },
))

Implementation

Stream<ActivityUpdate> get activityUpdateStream =>
    LiveActivitiesPlatform.instance.activityUpdateStream;