Flutter Dart : Streams

Saad El Oulladi
3 min readAug 26, 2019

For someone who just started learning Dart. Streams might be one trickiest features to learn. since in many languages , you need an extra library to have a Stream like components.

I think that Streams are particularly interesting since they allow you to do complex asynchronous tasks in a clean readable way.

Once you understand what Streams are about you will start frequently using them.

Before diving in Streams topic, it might be helpful to have an idea about Futures. since they are a simpler form of streams.
Here is my previous article about Futures in case you don’t know what they are.

Anyways here’s a little reminder :

Future allows to return some value “Later”, and it has three possible states :

  • Uncompleted.
  • Completed with success.
  • Completed with an error.

A stream does the same thing, with a key difference :

A future returns only one values. while a Stream returns many values.

This is theoretically the only difference, but in practice this implies some tricks we will try to cover bellow.

Let’s create our first stream :

--

--