ZenInfiniteQuery<T> class

A specialized query for infinite scrolling / pagination.

It manages a list of pages List<T> and handles fetching the next page based on the previous page's data.

T is the type of data in a single page (e.g. a Page object or a List of items).

Inheritance
Available extensions

Constructors

ZenInfiniteQuery({required Object queryKey, required Future<T> infiniteFetcher(dynamic pageParam, ZenCancelToken cancelToken), required dynamic getNextPageParam(T lastPage, List<T> allPages), dynamic getPreviousPageParam(T firstPage, List<T> allPages)?, dynamic initialPageParam, int? maxPages, ZenQueryConfig? config, List<T>? initialData, ZenScope? scope, bool autoDispose = true})

Properties

activeWatcherCount → int
Get count of active watchers (useful for debugging)
no setterinherited
autoDispose → bool
Whether to automatically dispose when scope disposes
finalinherited
childControllerCount → int
Get count of tracked child controllers for debugging
no setterinherited
childControllerStats → Map<String, int>
Get stats about child controllers
no setterinherited
config → ZenQueryConfig<List<T>>
Configuration for this query
finalinherited
createdAt → DateTime
no setterinherited
data → Rx<List<T>?>
Current data (null if not loaded yet)
finalinherited
enabled → RxBool
Whether the query is enabled to fetch data
finalinherited
error → Rx<Object?>
Current error (null if no error)
finalinherited
fetcher → ZenQueryFetcher<List<T>>
Function that fetches the data
finalinherited
fetchStatus → Rx<ZenQueryFetchStatus>
Current network fetch status
finalinherited
getNextPageParam → dynamic Function(T lastPage, List<T> allPages)
Function to determine the next page param based on the last page. Return null if there are no more pages.
final
getPreviousPageParam → dynamic Function(T firstPage, List<T> allPages)?
Function to determine the previous page param based on the first page. Return null if there are no previous pages.
final
hasData → bool
Whether the query has data
no setterinherited
hasError → bool
Whether the query has an error
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasNextPage → RxBool
final
hasPreviousPage → RxBool
final
infiniteFetcher → Future<T> Function(dynamic pageParam, ZenCancelToken cancelToken)
The actual fetcher that takes a page param and a cancel token.
final
initialData → List<T>?
Optional initial data
finalinherited
initialPageParam → dynamic
The initial page parameter to use for the first page.
final
isDisposed → bool
Whether this query has been disposed
no setterinherited
isFetching → bool
Whether this query is currently fetching data from the network
no setterinherited
isFetchingNextPage → RxBool
final
isFetchingPreviousPage → RxBool
final
isInitialized → bool
no setterinherited
isLoading → RxBool
Whether the query is currently loading
no setterinherited
isPlaceholderData → RxBool
Whether the current data is placeholder data
finalinherited
isReady → bool
no setterinherited
isRefetching → bool
Whether the query is currently refetching (loading while having data)
no setterinherited
isStale → bool
Whether data is stale and needs refetching
no setterinherited
maxPages → int?
Maximum number of pages to keep in memory at any one time.
final
queryKey → String
Unique key for this query (used for caching and deduplication)
finalinherited
reactiveObjectCount → int
Get count of tracked reactive objects for debugging
no setterinherited
reactiveStats → Map<String, int>
Get stats about reactive objects
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scope → ZenScope?
Optional scope - if provided, query will be tied to this scope
finalinherited
status → Rx<ZenQueryStatus>
Current status of the query
finalinherited
tags → List<String>
Tags for group-based invalidation.
finalinherited

Methods

addDisposer(void disposer()) → void
Add a disposer function that will be called when the controller is disposed
inherited
addUpdateListener(String updateId, VoidCallback listener) → void
Register a listener for a specific update ID
inherited
cancel([String reason = 'Query cancelled']) → void
Cancel any pending or in-flight fetch request for this query.
inherited
condition<T>(ValueNotifier<T> obs, bool condition(T), void callback(T)) → ZenWorker
inherited
createEffect<T>({required String name}) → ZenEffect<T>
Create an effect that will be auto-disposed with this controller
inherited
createWorkerGroup() → ZenWorkerGroup
Create a managed worker group
inherited
createWorkers(List<ZenWorker Function()> creators) → List<ZenWorker>

Available on ZenController, provided by the ZenControllerWorkerExtension extension

Create multiple workers in one call
debounce<T>(ValueNotifier<T> obs, void callback(T), Duration duration) → ZenWorker
inherited
didChangeAppLifecycleState(AppLifecycleState state) → void
Override from WidgetsBindingObserver to handle app lifecycle
inherited
dispose() → void
Dispose the controller and clean up ALL resources - PREVENTS MEMORY LEAKS
inherited
disposeWorkers(List<ZenWorker> workers) → void

Available on ZenController, provided by the ZenControllerWorkerExtension extension

Dispose specific workers
ever<T>(ValueNotifier<T> obs, void callback(T)) → ZenWorker
Type-safe convenience worker methods
inherited
fetch({bool force = false}) → Future<List<T>>
Fetch or refetch data
override
fetchNextPage() → Future<void>
Fetch the next page of data.
fetchPreviousPage() → Future<void>
Fetch the previous page of data.
getResourceStats() → Map<String, dynamic>
Get comprehensive resource usage statistics
inherited
getWorkerStats() → Map<String, dynamic>
Get worker statistics for debugging/monitoring
inherited
interval<T>(ValueNotifier<T> obs, void callback(T), Duration duration) → ZenWorker
inherited
invalidate() → void
Invalidate query (mark as stale and refetch if active)
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
obs<T>(T initialValue) → Rx<T>
Create and auto-track a reactive variable - PREVENTS MEMORY LEAKS
inherited
obsList<T>([List<T>? initialValue]) → RxList<T>
Create and auto-track a reactive list - PREVENTS MEMORY LEAKS
inherited
obsMap<K, V>([Map<K, V>? initialValue]) → RxMap<K, V>
Create and auto-track a reactive map - PREVENTS MEMORY LEAKS
inherited
obsSet<T>([Set<T>? initialValue]) → RxSet<T>
Create and auto-track a reactive set - PREVENTS MEMORY LEAKS
inherited
once<T>(ValueNotifier<T> obs, void callback(T)) → ZenWorker
inherited
onClose() → void
User-defined cleanup hook - called before internal disposal
override
onDetached() → void
Called when the app is detached
inherited
onHidden() → void
Called when the app is hidden
inherited
onInactive() → void
Called when the app is inactive
inherited
onInit() → void
Internal method called by child controllers to auto-register with parent This is called automatically during child controller construction if a parent exists
inherited
onPause() → void
Called when the app is paused (goes to background)
inherited
onReady() → void
inherited
onResume() → void
Called when the app is resumed (comes back to foreground)
inherited
pause() → void
Pause this query
inherited
pauseAllWorkers() → void
Pause all workers managed by this controller
inherited
pauseSpecificWorkers(List<ZenWorker> workers) → void

Available on ZenController, provided by the ZenControllerWorkerExtension extension

Pause specific workers
performFetch() → Future<List<T>>
Perform the actual fetch with retry logic. Intended to be overridden by subclasses like ZenInfiniteQuery.
inherited
refetch() → Future<List<T>>
Refetch data (force refresh)
inherited
removeUpdateListener(String updateId, VoidCallback listener) → void
Remove a listener for a specific update ID
inherited
reset() → void
Reset query to idle state
inherited
resume() → void
Resume this query
inherited
resumeAllWorkers() → void
Resume all workers managed by this controller
inherited
resumeSpecificWorkers(List<ZenWorker> workers) → void

Available on ZenController, provided by the ZenControllerWorkerExtension extension

Resume specific workers
select<R>(R selector(List<T> data)) → ZenQuery<R>
Creates a derived query that selects a subset of data.
inherited
setData(List<T> newData) → void
Manually set data (for optimistic updates)
inherited
throttle<T>(ValueNotifier<T> obs, void callback(T), Duration duration) → ZenWorker
inherited
toString() → String
A string representation of this object.
inherited
trackController<T extends ZenController>(T controller) → T
Track a child controller (like ZenQuery, ZenStreamQuery) for automatic disposal
inherited
trackReactive(Rx reactive) → void
Manually track a reactive object (for external reactive objects)
inherited
update([List<String>? updateIds]) → void
Optimized update method that can notify specific listeners or all listeners
inherited
watch<T>(ValueNotifier<T> observable, void callback(T), {WorkerType type = WorkerType.ever, Duration? duration, bool condition(T)?}) → ZenWorker
Create workers that auto-dispose with controller
inherited
when({required Widget data(List<T> pages, bool hasNextPage, VoidCallback fetchNextPage), Widget loading()?, Widget error(Object error, VoidCallback retry)?, Widget idle()?, bool autoFetch = true, bool showStaleData = true}) → Widget

Available on ZenInfiniteQuery<T>, provided by the ZenInfiniteQueryWhenExtension extension

Builds UI declaratively based on the infinite query state.

Operators

operator ==(Object other) → bool
The equality operator.
inherited