QueryState<T> class
Represents the state of a single query.
This class is immutable and provides convenient getters for common states.
- Annotations
Constructors
- QueryState.error(Object error, [T? previousData])
-
Factory constructor for an error state.
previousDatacan be provided to show existing data even on error.factory - QueryState.idle()
-
Factory constructor for an initial idle state.
factory
- QueryState.loading([T? previousData])
-
Factory constructor for a loading state.
previousDatacan be provided to show existing data while loading.factory - QueryState.success(T data, {bool isStale = false})
-
Factory constructor for a success state.
factory
Properties
- data → T?
-
The data returned by the query. Null if no data has been fetched or on error.
final
- error → Object?
-
The error encountered during the query, if any
final
- hasData → bool
-
True if the query has data (even if it's stale or there's an error).
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isError → bool
-
True if the query encountered an error.
no setter
- isLoading → bool
-
True if the query is currently fetching data.
no setter
- isStale → bool
-
True if the data is considered stale and might be refetched in the background
final
- isSuccess → bool
-
True if the query has successfully fetched data.
no setter
- lastFetched → DateTime?
-
The timestamp when the data was last successfully fetched
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → QueryStatus
-
The current status of the query (e.g., loading, success, error)
final
Methods
-
copyWith(
{T? data, Object? error, QueryStatus? status, bool? isStale, DateTime? lastFetched}) → QueryState< T> - Creates a copy of this QueryState with updated values.
-
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