StreamSummaryBuilder<T, S> class
An implementation of StreamBuilderBase that folds new stream events into a summary and builds with the summary of stream events seen so far.
Use this class instead of StreamBuilder if you need a widget that represents the summary of all stream event so far instead of just the latest element. A common use case would be building a ListView with elements fetched asynchronously from a paginated Database Query.
T
is the type of stream events.
S
is the type of interaction summary. Summaries are wrapped in
AsyncSnapshot to give the builder access to the ConnectionState.
See also:
- StreamBuilder, which is specialized for the case where only the most recent interaction is needed for widget building.
- StreamBuilderBase, an abstract class that enables greater customization of summary and connection state behavior.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- StreamBuilderBase<
T, AsyncSnapshot< S> > - StreamSummaryBuilder
Constructors
-
StreamSummaryBuilder({Key? key, required S initialData, required Fold<
T, S> fold, Stream<T> ? stream, required AsyncWidgetBuilder<S> builder}) -
Create a stream summary builder with the provided arguments.
const
Properties
-
builder
→ AsyncWidgetBuilder<
S> -
Build a widget using a summary
S
of element seen so far.final -
fold
→ Fold<
T, S> -
A function that folds an element of type
T
into a summary of typeS
. See Fold.final - hashCode → int
-
The hash code for this object.
no setterinherited
- initialData → S
-
The summary object to use before any elements are received.
final
- key → Key?
-
Controls how one widget replaces another widget 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.
finalinherited
Methods
-
afterConnected(
AsyncSnapshot< S> current) → AsyncSnapshot<S> -
Returns an updated version of the
current
summary reflecting that we are now connected to a stream.override -
afterData(
AsyncSnapshot< S> current, T data) → AsyncSnapshot<S> -
Returns an updated version of the
current
summary following a data event.override -
afterDisconnected(
AsyncSnapshot< S> current) → AsyncSnapshot<S> -
Returns an updated version of the
current
summary reflecting that we are no longer connected to a stream.override -
afterDone(
AsyncSnapshot< S> current) → AsyncSnapshot<S> -
Returns an updated version of the
current
summary following stream termination.override -
afterError(
AsyncSnapshot< S> current, Object error, StackTrace stackTrace) → AsyncSnapshot<S> -
Returns an updated version of the
current
summary following an error with a stack trace.override -
build(
BuildContext context, AsyncSnapshot< S> currentSummary) → Widget -
Returns a Widget based on the
currentSummary
.override -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StreamBuilderBase< T, AsyncSnapshot< >S> > -
Creates the mutable state for this widget at a given location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
initial(
) → AsyncSnapshot< S> -
Returns the initial summary of stream interaction, typically representing
the fact that no interaction has happened at all.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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 DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
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 ==(
Object other) → bool -
The equality operator.
inherited