concept sink in category flutter

appears as: A Sink, sink, A sink, sink, sinks
Flutter in Action

This is an excerpt from Manning's book Flutter in Action.

A Sink is a specific subtype of stream controller—the standard type. When discussing the concept, sink refers to a stream controller.

Listing 9.1. Example Dart code using streams and sinks
// Streams and Sinks
StreamController<bool> _controller = StreamController<bool>();
Stream get onEvent => _controller.stream;
 
void handleEvent() {
    onEvent.listen((val) => print(val));
}
 
// async / await
void getRequest() async {
    var response = await http.get(url);
    return response;
}
  • Sinks are the first stop for events in the observer pattern. A sink is the piece of the puzzle that you feed data into. It’s kind of the central source for the whole process. In Dart, a Sink is an abstract class that’s implemented by more specific types of sinks. The most common of these is the StreamController.
  • Streams are properties on the Sink. When the sink needs to notify listeners of new events, it does so via streams.
  • StreamController objects are used to define streams and sinks.
  • A Sink is the entry point of data for a stream.