repeat<T> method Null safety

Stream<T> repeat<T>(
  1. Stream<T> streamFactory(
    1. int repeatIndex
  2. [int? count]

Creates a Stream that will recreate and re-listen to the source Stream the specified number of times until the Stream terminates successfully.

If count is not specified, it repeats indefinitely.


RepeatStream((int repeatCount) =>
  Stream.value('repeat index: $repeatCount'), 3)
    .listen((i) => print(i)); // Prints 'repeat index: 0, repeat index: 1, repeat index: 2'


static Stream<T> repeat<T>(Stream<T> Function(int repeatIndex) streamFactory,
        [int? count]) =>
    RepeatStream<T>(streamFactory, count);