StreamBuilderBase<T, S> class

Base class for widgets that build themselves based on interaction with a specified Stream.

A StreamBuilderBase is stateful and maintains a summary of the interaction so far. The type of the summary and how it is updated with each interaction is defined by sub-classes.

Examples of summaries include:

  • the running average of a stream of integers;
  • the current direction and speed based on a stream of geolocation data;
  • a graph displaying data points from a stream.

In general, the summary is the result of a fold computation over the data items and errors received from the stream along with pseudo-events representing termination or change of stream. The initial summary is specified by sub-classes by overriding initial. The summary updates on receipt of stream data and errors are specified by overriding afterData and afterError, respectively. If needed, the summary may be updated on stream termination by overriding afterDone. Finally, the summary may be updated on change of stream by overriding afterDisconnected and afterConnected.

T is the type of stream events.

S is the type of interaction summary.

See also:

  • StreamBuilder, which is specialized for the case where only the most recent interaction is needed for widget building.
Inheritance
Implementers

Constructors

StreamBuilderBase({Key key, Stream<T> stream })
Creates a StreamBuilderBase connected to the specified stream.
const

Properties

stream Stream<T>
The asynchronous computation to which this builder is currently connected, possibly null. When changed, the current summary is updated using afterDisconnected, if the previous stream was not null, followed by afterConnected, if the new stream is not null.
final
hashCode int
The hash code for this object. [...]
read-only, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

afterConnected(S current) → S
Returns an updated version of the current summary reflecting that we are now connected to a stream. [...]
afterData(S current, T data) → S
Returns an updated version of the current summary following a data event. [...]
afterDisconnected(S current) → S
Returns an updated version of the current summary reflecting that we are no longer connected to a stream. [...]
afterDone(S current) → S
Returns an updated version of the current summary following stream termination. [...]
afterError(S current, Object error) → S
Returns an updated version of the current summary following an error. [...]
build(BuildContext context, S currentSummary) Widget
Returns a Widget based on the currentSummary.
createState() State<StreamBuilderBase<T, S>>
Creates the mutable state for this widget at a given location in the tree. [...]
override
initial() → S
Returns the initial summary of stream interaction, typically representing the fact that no interaction has happened at all. [...]
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
inherited
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited