flatMap<S> method Null safety

Stream<S> flatMap<S>(
  1. Stream<S> mapper(
    1. T value

Converts each emitted item into a Stream using the given mapper function. The newly created Stream will be be listened to and begin emitting items downstream.

The items emitted by each of the Streams are emitted downstream in the same order they arrive. In other words, the sequences are merged together.


RangeStream(4, 1)
  .flatMap((i) => TimerStream(i, Duration(minutes: i)))
  .listen(print); // prints 1, 2, 3, 4


Stream<S> flatMap<S>(Stream<S> Function(T value) mapper) =>
    transform(FlatMapStreamTransformer<T, S>(mapper));