Stream<T>.empty constructor
- {@Since("3.2") bool broadcast}
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');
},
);
The stream defaults to being a broadcast stream,
as reported by isBroadcast.
This value can be changed by passing false
as
the broadcast
parameter, which defaults to true
.
The stream can be listened to more than once, whether it reports itself as broadcast or not.
Implementation
const factory Stream.empty({@Since("3.2") bool broadcast}) = _EmptyStream<T>;