Stream<T>.value constructor

  1. @Since("2.5")
Stream<T>.value(T value)

Creates a stream which emits a single data event before completing.

This stream emits a single data event of value and then completes with a done event.


Future<void> printThings(Stream<String> data) async {
  await for (var x in data) {
printThings(Stream<String>.value("ok")); // prints "ok".

The returned stream is effectively equivalent to one created by (() async* { yield value; } ()) or Future<T>.value(value).asStream().


factory Stream.value(T value) =>
    (_AsyncStreamController<T>(null, null, null, null)