presentSingleValueStream method

void presentSingleValueStream()

Implementation

void presentSingleValueStream() {
  var data = intList;
  Stream stream = Stream.fromIterable(data);
  var broadcastStream = stream.asBroadcastStream();

  broadcastStream
      .singleWhere(
          (value) => value < 2) // there is only one value less than 2
      .then((value) =>
          print("\n  single value: $value  \n ---    OK  ----  \n "));
  // outputs: single value: 1
}