dart / 2.17.0 / dart-async / stream / stream.empty.html /

Stream<T>.empty constructor

const Stream< T>.empty( )

Creates an empty broadcast stream.

This is a stream which does nothing except sending a done event when it's listened to.

Example:

const stream = Stream.empty();
stream.listen(
  (value) {
    throw "Unreachable";
  },
  onDone: () {
    print('Done');
  },
);

Implementation

const factory Stream.empty() = _EmptyStream<T>;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.17.0/dart-async/Stream/Stream.empty.html