-
Book Overview & Buying
-
Table Of Contents
Flutter Cookbook, Second Edition - Second Edition
By :
StreamControllers create a linked Stream and Sink. While streams contain data emitted sequentially that can be received by any subscriber, sinks are used to insert events.
StreamControllers simplify stream management, automatically creating a stream and a sink, and methods to control their events and features.
In this recipe, you will create a stream controller to listen to and insert new events. This will show you how to fully control a stream.
In order to follow along with this recipe, you should have completed the code in the previous recipe, How to use Dart streams.
For this recipe, we will make our app display a random number on the screen, leveraging StreamControllers and their sink property:
stream.dart file, import the dart:async library:
import 'dart:async';
stream.dart file, add a new class, called NumberStream...