Enabled class sealed Option values

Whether a query may fetch on its own — the enabled option.

A disabled query never fetches by itself: not when an observer mounts, not on focus, reconnect, polling or invalidation. It still serves whatever the cache holds, and an explicit refetch() on its observer still fetches. Use it for dependent queries (wait until an id is known) or to pause a query.

Default: Enabled.yes.

enabled: Enabled.yes                     // the default
enabled: Enabled.no                      // only an explicit refetch
enabled: userId == null ? Enabled.no : Enabled.yes   // dependent query
enabled: Enabled.when((query) => query.state.data == null) // until loaded
Implementers
Annotations
  • @immutable

Constructors

Enabled.when(bool predicate(Query<Object?> query))
Decided per query, each time it matters (TanStack Query: enabled: (query) => boolean). A predicate that reads the query's state can, for instance, keep a query enabled only until it first succeeds.
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
resolve(Query<Object?> query) → bool
Whether query may fetch on its own right now.
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

no → const Enabled
The query never fetches on its own (TanStack Query: enabled: false). It still serves cached data, and a refetch() still works.
yes → const Enabled
The query fetches on its own: on mount, on every refetch trigger, and when invalidated. The default.