Streams In Flutter

Save

Streams In Flutter are like pipes. If you put a value on one end and have a listener on the other end, that listener will pick it up. A stream can have multiple listeners, all of which get the same value when they enter the pipeline. Use a StreamController to put values ​​into a stream.Streams provide an asynchronous sequence of data.

Type of Streams : There are two type of streams.

  1. Single Subscription: There could be a maximum of one listener to this stream.
  2. Broadcast: There could be the infinite number of the listener to this stream.

1. Single Subscription Stream:

A single subscription stream works great when you’re only using certain streams on a screen. You can only listen to one subscription stream once. It won’t start generating events until there is a listener, and will stop sending events when the listener stops listening, even if the source of the event can provide more data. 

A single subscription stream is useful for file downloads or single operations. For example, a widget can subscribe to a stream to get value updates.

2. Broadcast streams:

If you need multiple parts of your app to access the same stream, use broadcast streams instead. A broadcast stream can have any number of listeners. Occurswhen an event is ready, with or without listeners. To create a broadcast stream, simply call asBroadcastStream() on an existing single subscription stream.

Conclusion:

I hope you get the rough idea to how to use Stream in Flutter. For reference you can also check here.

To read more Mobikul blogs, Please click here.

Thanks for reading…

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.

Stathis Plakidas

Stathis Plakidas

Talk to Sales

Global

Live Chat
Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home