ZenQueryBuilder<T> class

A widget that builds itself based on the state of a ZenQuery.

It handles the main states:

  • loading: Query is fetching and no data exists yet.
  • error: Query failed.
  • builder: Query has data (or placeholder data).

Example:

ZenQueryBuilder<User>(
  query: userQuery,
  builder: (context, data) => Text(data.name),
  loading: () => CircularProgressIndicator(),
  error: (error, retry) => ErrorView(error, retry),
);
Inheritance

Constructors

ZenQueryBuilder({Key? key, required ZenQuery<T> query, required Widget builder(BuildContext context, T data), Widget loading()?, Widget error(Object error, VoidCallback retry)?, Widget idle()?, bool autoFetch = true, bool showStaleData = true, bool keepPreviousData = false, Widget wrapper(BuildContext context, Widget child)?})
const

Properties

autoFetch bool
Whether to automatically fetch on mount
final
builder Widget Function(BuildContext context, T data)
Builder for success state with data
final
error Widget Function(Object error, VoidCallback retry)?
Builder for error state with retry function
final
hashCode int
The hash code for this object.
no setterinherited
idle Widget Function()?
Builder for idle state (before first fetch)
final
keepPreviousData bool
If true, keeps showing the data from the previous query instance (if available) while the new query is loading.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loading Widget Function()?
Builder for loading state
final
query ZenQuery<T>
The query to observe
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showStaleData bool
Whether to show stale data while refetching
final
wrapper Widget Function(BuildContext context, Widget child)?
Custom wrapper for all states
final

Methods

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