We have seen the Future class in a previous publication, we can now start learning a bit more about the Stream class. In fact, the Future.asStream() method was already there to show a quick example how work a Stream .
What a difference with a Future ? Well, a Future is dealing with only one event, a Stream deals with a sequence of events. This sequence of events can be created using yield* . In this case, the function needs to be marked with async* , and will return a Stream<E> where E is the event type. In short, you can see these objects like an Iterable with side effects.
A source of asynchronous data events.
-- Dart Language Documentation, Stream class
Like for the Future class, I will try to take few interesting methods/constructors from the Stream class and give some example with use cases.
Single vs Broadcast Streams
A single-subscription Stream is a finite sequence of events, having a beginning and an ending. Only one listener can be configured this kind of objects.…