splitFrom<T> method Null safety

List<Stream<T>> splitFrom<T>(
  1. Stream<T> stream,
  2. [int? count]

Splits stream into count identical streams.

count defaults to 2. This is the same as creating count branches and then closing the StreamSplitter.


static List<Stream<T>> splitFrom<T>(Stream<T> stream, [int? count]) {
  count ??= 2;
  var splitter = StreamSplitter<T>(stream);
  var streams = List<Stream<T>>.generate(count, (_) => splitter.split());
  return streams;