PlaceholderData<TQueryData> class sealed Option values

The value of QueryObserverOptionsBase.placeholderData: data an observer shows while its query has none of its own.

A placeholder is never written to the cache. It belongs to the observer that asked for it, the result built from it reports isPlaceholderData, and it gives way the moment real data arrives. There is no default — unset, an observer without data reports a pending result.

  • PlaceholderData.keepPrevious() — keeps what this observer showed for the previous key while the new key loads: page 2 stays on screen until page 3 arrives, instead of a spinner in between.
  • PlaceholderData.value(Task.empty) — a fixed placeholder.
  • PlaceholderData.compute((previousData, previousQuery) => ...) — a placeholder computed from what the observer showed last.
Implementers
Annotations
  • @immutable

Constructors

PlaceholderData.compute(TQueryData? compute(TQueryData? previousData, Query<TQueryData>? previousQuery))
The callback form: return previousData to keep the last page's content on screen while the new key loads, or anything else derived from it. Returning null means no placeholder.
const
factory
PlaceholderData.keepPrevious()
Keeps the previous data while the new key loads. A previous null means no placeholder, just as .compute((previous, _) => previous).
const
factory
PlaceholderData.value(TQueryData data)
A fixed placeholder, shown whenever the query has no data of its own (TanStack Query: placeholderData: value).
const
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
provide(TQueryData? previousData, Query<TQueryData>? previousQuery) → ({TQueryData? data, bool hasData})
The placeholder, and whether there is one. Same rule as InitialData.seed: .value(null) is a placeholder of null, while .compute returning null means "none".
toString() → String
A string representation of this object.
inherited

Operators

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