QuerySelectBuilder<TQueryData, TData> class
Reading queries
QueryBuilder for a query with a select: the cache holds TQueryData,
the builder sees TData.
QuerySelectBuilder<Task, String>(
options: QuerySelectOptions(
queryKey: QueryKey(['tasks', id]),
queryFn: (_) => api.getTask(id),
select: (task) => task.name,
),
builder: (context, result) => Text(result.dataOrNull ?? '…'),
)
Takes a QuerySelectOptions, whose required select is what lets Dart
infer the second type. Everything else — lifetime, options re-applied
when the parent rebuilds, buildWhen, client — is as for
QueryBuilder. A select
that returns an equal value keeps the previous one, so data stays the
same instance when nothing it depends on changed; the rest of the result
(fetchStatus, dataUpdatedAt) still changes, which is what
buildWhen is for.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- QuerySelectBuilder
Constructors
-
QuerySelectBuilder({Key? key, required QuerySelectOptions<
TQueryData, TData> options, required Widget builder(BuildContext context, QueryResult<TData> result), BuildWhen<QueryResult< ? buildWhen, QueryClient? client})TData> > -
Observes
options's query,selectincluded, onclientor else the nearest QueryClientProvider's, and handsbuilderthe selected result.const
Properties
-
builder
→ Widget Function(BuildContext context, QueryResult<
TData> result) -
Builds this widget's subtree from the selected result —
TData, not theTQueryDatathe cache holds. Called on the first build and then whenever the result changes and buildWhen lets it through.final -
buildWhen
→ BuildWhen<
QueryResult< ?TData> > -
Whether a change from the result last built to the current one is worth
a rebuild;
nullrebuilds for every changed result. Compares selected results; see QueryBuilder.buildWhen.final - client → QueryClient?
-
The client to observe on;
nulluses the nearest QueryClientProvider's. A different client on a later build recreates the observer; see QueryBuilder.client.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
options
→ QuerySelectOptions<
TQueryData, TData> -
The query and its
select. Re-applied whenever the parent rebuilds this widget; the observer decides what changed, as for QueryBuilder.options.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< QuerySelectBuilder< TQueryData, TData> > -
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