withLatestFromList method Null safety

Stream<List<T>> withLatestFromList(
  1. Iterable<Stream<T>> latestFromStreams

Creates a Stream that emits when the source stream emits, combining the latest values from the streams into a list. This is helpful when you need to combine a dynamic number of Streams.

If any of latestFromStreams has not emitted any values, this stream will not emit either.

Interactive marble diagram


Stream.fromIterable([1, 2]).withLatestFromList(
      Stream.fromIterable([2, 3]),
      Stream.fromIterable([3, 4]),
      Stream.fromIterable([4, 5]),
      Stream.fromIterable([5, 6]),
      Stream.fromIterable([6, 7]),
  ).listen(print); // print [2, 2, 3, 4, 5, 6] (due to the async nature of streams)


Stream<List<T>> withLatestFromList(Iterable<Stream<T>> latestFromStreams) =>