watchStream<T extends Object, R> method

AsyncSnapshot<R> watchStream<T extends Object, R>(
  1. Stream<R> select(
    1. T
    ),
  2. R initialValue, {
  3. String? instanceName,
  4. bool preserveState = true,
})

subscribes to the Stream returned by select and returns an AsyncSnapshot with the latest received data from the Stream Whenever new data is received it triggers a rebuild. When you call watchStream a second time on the same Stream it will return the last received data but not subscribe another time. To be able to use watchStream inside a build function we have to pass initialValue so that it can return something before it has received the first data if select returns a different Stream than on the last call, watchStream will cancel the previous subscription and subscribe to the new stream. preserveState determines then if the new initial value should be the last value of the previous stream or again initialValue

Implementation

AsyncSnapshot<R> watchStream<T extends Object, R>(
  Stream<R> Function(T) select,
  R initialValue, {
  String? instanceName,
  bool preserveState = true,
}) =>
    _state.value.watchStream<T, R>(select, initialValue,
        instanceName: instanceName, preserveState: preserveState);