ValueStreamListener<M, T> class
Takes a ValueStreamWidgetListener and a stream and invokes
the listener in response to value changes in the stream.
It should be used for functionality that needs to occur only in response to
a value change such as navigation, showing a SnackBar, showing
a Dialog, etc...
The listener is guaranteed to only be called once for each value change
unlike the builder in ValueStreamBuilder.
ValueStreamListener requires stream.hasValue to always be true,
and the stream does not emit any error events.
See ValueStreamHasNoValueError and UnhandledStreamError
for more information.
Example
ValueStreamListener<T>(
stream: valueStream,
listener: (context, previous, current) {
// do stuff here based on valueStream's
// previous and current values
},
child: Container(),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ValueStreamListener
Constructors
-
ValueStreamListener({Key? key, required ValueStream<
M> stream, T? distinctBy(M event)?, required ValueStreamWidgetListener<M, T> listener, required Widget child, bool isReplayValueStream = true}) -
Takes a ValueStreamWidgetListener and a stream and invokes
the listener in response to
valuechanges in the stream.const
Properties
- child → Widget
-
The widget which will be rendered as a descendant of the
ValueStreamListener.
final
- distinctBy → T? Function(M event)?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isReplayValueStream → bool
-
Whether or not the stream emits the last value
like
BehaviorSubjectdoes.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
listener
→ ValueStreamWidgetListener<
M, T> -
listener: (context, preDistinct, curDistinct, value) {}final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ ValueStream<
M> -
The ValueStream that the ValueStreamConsumer will interact with.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ValueStreamListener< M, T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
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, int wrapWidth = 65}) → 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