StreamBuilderBase<T, S> class
abstract
Base class for components 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 component building.
- Inheritance
-
- Object
- Component
- StatefulComponent
- StreamBuilderBase
- Implementers
Constructors
-
StreamBuilderBase({Key? key, Stream<
T> ? stream}) -
Creates a StreamBuilderBase connected to the specified stream.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one component replaces another component in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
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
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, StackTrace stackTrace) → S -
Returns an updated version of the
current
summary following an error with a stack trace. -
build(
BuildContext context, S currentSummary) → Iterable< Component> -
Returns a Component based on the
currentSummary
. -
createElement(
) → Element -
Creates a StatefulElement to manage this component's location in the tree.
inherited
-
createState(
) → State< StreamBuilderBase< T, S> > -
Creates the mutable state for this component 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.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited