QueryListener<T> class

An internal widget used by useQuery and useMutation (or similar hooks) to listen to streams and trigger widget rebuilds.

This widget serves as a robust listener that handles stream lifecycle:

  • Displays initial data on first build.
  • Rebuilds its child whenever the subscribed stream emits a new value.
  • Unsubscribes from the old stream and subscribes to a new one if the stream instance changes in didUpdateWidget.
  • Cancels its subscription cleanly when the widget is disposed to prevent memory leaks and unnecessary processing.
Inheritance

Constructors

QueryListener({Key? key, required Stream<T> stream, required T initialData, required Widget builder(BuildContext context, T data)})
Creates a QueryListener widget.
const

Properties

builder Widget Function(BuildContext context, T data)
A builder function that receives the current data from the stream. This function is called every time the data updates, triggering a rebuild of the subtree defined by the builder.
final
hashCode int
The hash code for this object.
no setterinherited
initialData → T
The initial data to use before the first value from the stream is received. This value is displayed immediately upon widget creation.
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 stream to listen to for data updates.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<QueryListener<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.
inherited
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