Broadcast Stream #1
In this lesson, you will learn about Broadcast Stream operations
We'll cover the following
Broadcast Streams operations
In this lesson, you will learn to convert a single subscription stream to a broadcast Stream by using the asBroadcastStream()
method.
Single Subscription Stream:
//This will generate a stream and return a reference to it.
Stream<int> createNumberStream(int last) async* {
for (int i = 1; i <= last; i++) {
yield i; //to be able to send spaced out events
}
}
Basic Operations
Let’s convert this single subscription Stream to a broadcast Stream using the asBroadcastStream()
method and re-examine all properties again.
This time we do not need to create a fresh Stream for each operation. Broadcast Streams can have multiple subscribers or can be listened to multiple times.
All the basic operations are carried out on the same Stream.
Get hands-on with 1400+ tech skills courses.