dart:async
StreamController<T> class
A controller with the stream it controls.
This controller allows sending data, error and done events on its stream. This class can be used to create a simple stream that others can listen on, and to push events to that stream.
It's possible to check whether the stream is paused or not, and whether it has subscribers or not, as well as getting a callback when either of these change.
- Implements
-
- Implemented by
Constructors
- StreamController({void onListen(), void onPause(), void onResume(), dynamic onCancel(), bool sync: false })
factory
- A controller with a stream that supports only one single subscriber. [...]
- StreamController.broadcast({void onListen(), void onCancel(), bool sync: false })
factory
- A controller where stream can be listened to more than once. [...]
Properties
- hasListener → bool
read-only
- Whether there is a subscriber on the Stream.
- isClosed → bool
read-only
- Whether the stream controller is closed for adding more events. [...]
- isPaused → bool
read-only
- Whether the subscription would need to buffer events. [...]
- onCancel ↔ ControllerCancelCallback
read / write
- The callback which is called when the stream is canceled. [...]
- onListen ↔ ControllerCallback
read / write
- The callback which is called when the stream is listened to. [...]
- onPause ↔ ControllerCallback
read / write
- The callback which is called when the stream is paused. [...]
- onResume ↔ ControllerCallback
read / write
- The callback which is called when the stream is resumed. [...]
- sink → StreamSink<T>
read-only
- Returns a view of this object that only exposes the StreamSink interface.
- stream → Stream<T>
read-only
- The stream that this controller is controlling.
- done → Future
read-only, inherited
- Return a future which is completed when the StreamSink is finished. [...]
- hashCode → int
read-only, inherited
- The hash code for this object. [...]
- runtimeType → Type
read-only, inherited
- A representation of the runtime type of the object.
Methods
- add(T event) → void
- Sends a data
event
. [...] - addError(Object error, [ StackTrace stackTrace ]) → void
- Sends or enqueues an error event. [...]
- addStream(Stream<T> source, { bool cancelOnError }) → Future
- Receives events from
source
and puts them into this controller's stream. [...] - close() → Future
- Closes the stream. [...]
- noSuchMethod(Invocation invocation) → dynamic
inherited
- Invoked when a non-existent method or property is accessed. [...]
- toString() → String
inherited
- Returns a string representation of this object.
Operators
- operator ==(dynamic other) → bool
inherited
- The equality operator. [...]