10
Advanced State Management with Streams
In Dart and Flutter, futures and streams are the main tools to deal with asynchronous programming.
While Future
represents a single value that will be delivered at a later time in the future, Stream
is a set (sequence) of values (0 or more) that can be delivered asynchronously, at any time. Basically, it is a flow of continuous data.
In order to get data from a stream, you subscribe (or listen) to it. Each time some data is emitted, you can receive and manipulate it as required by the logic of your app.
By default, each stream allows only a single subscription, but you will also see how to enable multiple subscriptions.
This chapter focuses on several use cases of streams in a Flutter app. You will ...
Get Flutter Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.