InfiniteQueryBuilder<TPageData, TPageParam, TData> class Infinite queries

Builds its subtree from an infinite query, handing the builder the InfiniteQueryController so it can page.

InfiniteQueryBuilder(
  options: feedQuery(),
  builder: (context, feed) {
    final posts = feed.value.dataOrNull?.flatten<Post>() ?? const <Post>[];
    return ListView(
      children: [
        for (final post in posts) ListTile(title: Text(post.title)),
        if (feed.hasNextPage)
          TextButton(
            onPressed: feed.isFetchingNextPage ? null : feed.fetchNextPage,
            child: const Text('Load more'),
          ),
      ],
    );
  },
)

No type arguments at the call site: either options shape — InfiniteQueryObserverOptions or InfiniteQuerySelectOptions — carries the page type, the page-param type and the result type, and inference reads all three off it.

The widget owns the controller from its first build until it is disposed; do not dispose the one builder is handed. Options are re-applied whenever the parent rebuilds it, as for QueryBuilder. A fetch that moves only the paging flags — isFetchingNextPage, hasNextPage and the like — rebuilds too, even when the result itself is unchanged.

Inheritance

Constructors

InfiniteQueryBuilder({Key? key, required InfiniteQueryObserverOptionsBase<TPageData, TPageParam, TData> options, required Widget builder(BuildContext context, InfiniteQueryController<TPageData, TPageParam, TData> query), BuildWhen<QueryResult<TData>>? buildWhen, QueryClient? client})
Observes options's infinite query on client or else the nearest QueryClientProvider's, and hands builder the controller, which is where paging lives.
const

Properties

builder → Widget Function(BuildContext context, InfiniteQueryController<TPageData, TPageParam, TData> query)
Builds this widget's subtree from the infinite query, given its controller rather than a bare result: the pages are in query.value, and InfiniteQueryController.hasNextPage, InfiniteQueryController.fetchNextPage and the other paging members are on the controller. 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; null rebuilds for every changed result. Compares the controller's results (see QueryBuilder.buildWhen); a change of the paging flags alone rebuilds regardless.
final
client → QueryClient?
The client to observe on; null uses the nearest QueryClientProvider's. A different client on a later build recreates the controller; 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 → InfiniteQueryObserverOptionsBase<TPageData, TPageParam, TData>
The infinite query: key, page function and paging functions. 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<InfiniteQueryBuilder<TPageData, TPageParam, 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