ValueStreamListener<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: source,
listener: (context, previous, current) {
// do stuff here based on source
// previous and current values
},
child: Container(),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ValueStreamListener
- Available extensions
Constructors
-
ValueStreamListener({Key? key, ValueStream<
T> ? stream, StateStreamable<T> ? bloc, required ValueStreamWidgetListener<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
-
bloc
→ StateStreamable<
T> ? -
Bloc-native state source. Prefer this for new code.
final
- child → Widget
-
The widget which will be rendered as a descendant of the
ValueStreamListener.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isReplayValueStream → bool
-
Whether or not the stream emits the last value
like FlowR streams do.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
listener
→ ValueStreamWidgetListener<
T> -
Takes the
BuildContextalong with thepreviousandcurrentvalues and is responsible for executing in response tovaluechanges.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ ValueStream<
T> ? -
The ValueStream that the legacy ValueStreamListener will interact with.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ValueStreamListener< 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
-
distinctBy<
T> (Object key(T)) → bool Function(T, T) -
Available on Widget, provided by the WidgetDistinctByX extension
buildWhen: (p, c) => p.userId != p.userId && p.name != c.name, buildWhen: (p, c) => (p.userId, p.name) != (p.name, c.name), buildWhen: distinctBy((e) => (e.userId, e.name)), -
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