Loading<T> class final

Loading state - actively fetching data.

previousData contains data from a previous successful fetch, if any. This enables showing stale data while refreshing, improving UX.

Example:

// First fetch
Loading(previousData: null) // Show spinner

// Refetch
Loading(previousData: oldData) // Show stale data + subtle loading indicator
Inheritance
Available extensions
Annotations
  • @immutable

Constructors

Loading({T? previousData})
const

Properties

dataOrNull → T?
Extracts data from any state that has it, or returns null.
no setterinherited
errorOrNull Object?
Extracts error from Failure state, or returns null.
no setterinherited
hasData bool
Returns true if this state contains usable data.
no setterinherited
hasError bool

Available on QoraState<T>, provided by the QoraStateExtensions extension

Returns true if state has an error.
no setter
hashCode int
The hash code for this object.
no setteroverride
isError bool
Returns true if in error state.
no setterinherited
isFirstLoad bool

Available on QoraState<T>, provided by the QoraStateExtensions extension

Returns true if this is a first-time loading (no previous data).
no setter
isInitial bool
Returns true if initial (not started).
no setterinherited
isLoading bool
Returns true if actively loading.
no setterinherited
isRefreshing bool

Available on QoraState<T>, provided by the QoraStateExtensions extension

Returns true if this is a refresh (loading with previous data).
no setter
isSuccess bool
Returns true if successful.
no setterinherited
previousData → T?
Data from previous successful fetch, if any.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status ReqryStatus

Available on QoraState<T>, provided by the QoraStateExtensions extension

Converts state to a simple status enum.
no setter
successDataOrNull → T?

Available on QoraState<T>, provided by the QoraStateExtensions extension

Returns data if Success, null otherwise (ignores previousData).
no setter
updatedAt DateTime?

Available on QoraState<T>, provided by the QoraStateExtensions extension

Gets the timestamp when data was last updated.
no setter

Methods

combine<T2, R>(QoraState<T2> other, R combiner(T data1, T2 data2)) QoraState<R>

Available on QoraState<T>, provided by the QoraStateExtensions extension

Combines this state with another state using a combiner function.
fold<R>({required R onInitial(), required R onLoading(T? previousData), required R onSuccess(T data, DateTime updatedAt), required R onError(Object error, StackTrace? stackTrace, T? previousData)}) → R

Available on QoraState<T>, provided by the QoraStateExtensions extension

Folds the state into a single value of type R.
isStale(Duration threshold) bool

Available on QoraState<T>, provided by the QoraStateExtensions extension

Checks if data is stale based on a threshold.
map<R>(R transform(T data)) QoraState<R>
Maps the data type while preserving state structure.
inherited
mapSuccess<R>(R transform(T data)) QoraState<R>

Available on QoraState<T>, provided by the QoraStateExtensions extension

Maps only if state is Success, otherwise returns the state as-is.
maybeWhen<R>({required R orElse(), R onInitial()?, R onLoading(T? previousData)?, R onSuccess(T data, DateTime updatedAt)?, R onError(Object error, StackTrace? stackTrace, T? previousData)?}) → R
Maps the state to a value of type R based on callbacks.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requireData() → T

Available on QoraState<T>, provided by the QoraStateExtensions extension

Returns the data if available, or throws an error.
toJson(Map<String, dynamic> dataToJson(T data)) Map<String, dynamic>

Available on QoraState<T>, provided by the QoraStateSerializationX extension

Serializes this state to JSON.
toJsonString(Map<String, dynamic> dataToJson(T data)) String

Available on QoraState<T>, provided by the QoraStateSerializationX extension

Serializes this state to a JSON string.
toString() String
A string representation of this object.
override
when({void onInitial()?, void onLoading(T? previousData)?, void onSuccess(T data, DateTime updatedAt)?, void onError(Object error, StackTrace? stackTrace, T? previousData)?}) → void
Executes a callback based on the current state.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override