QueryResult<T> class
Immutable result of a query, containing data, error, and status information.
Widgets use this to decide what to render (loading, error, or data).
Constructors
- QueryResult({T? data, Object? error, StackTrace? errorStackTrace, required QueryStatus status, bool isPreviousData = false, DateTime? dataUpdatedAt, DateTime? errorUpdatedAt, required VoidCallback refetch})
-
Creates a query result.
const
- QueryResult.idle({required VoidCallback refetch})
-
Creates an idle result (query not yet triggered).
factory
- QueryResult.loading({required VoidCallback refetch})
-
Creates a loading result.
factory
Properties
- data → T?
-
The cached data, or
nullif not yet fetched.final - dataUpdatedAt → DateTime?
-
When data was last successfully fetched.
final
- error → Object?
-
The error from the last failed fetch, or
null.final - errorStackTrace → StackTrace?
-
Stack trace from the last failed fetch.
final
- errorUpdatedAt → DateTime?
-
When an error was last received.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isError → bool
-
Whether the last fetch resulted in an error.
no setter
- isFetching → bool
-
Whether any fetch is in progress (initial or background).
no setter
- isIdle → bool
-
Whether the query is idle (disabled or never triggered).
no setter
- isLoading → bool
-
Whether this is the initial load with no data yet.
no setter
- isPreviousData → bool
-
truewhenkeepPreviousDatais active and showing data from a previously-subscribed key while the new key loads.final - isRefreshing → bool
-
Whether data exists and a background refresh is in progress.
no setter
- isSuccess → bool
-
Whether data was loaded successfully.
no setter
- refetch → VoidCallback
-
Triggers a manual refetch.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → QueryStatus
-
The current status of the query.
final
Methods
-
copyWith(
{T? data, Object? error, StackTrace? errorStackTrace, QueryStatus? status, bool? isPreviousData, DateTime? dataUpdatedAt, DateTime? errorUpdatedAt, VoidCallback? refetch, bool clearError = false, bool clearData = false}) → QueryResult< T> - Creates a copy with the given overrides.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override