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<
Returns true if state has an error.T> , provided by the QoraStateExtensions extensionno 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<
Returns true if this is a first-time loading (no previous data).T> , provided by the QoraStateExtensions extensionno 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<
Returns true if this is a refresh (loading with previous data).T> , provided by the QoraStateExtensions extensionno 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<
Converts state to a simple status enum.T> , provided by the QoraStateExtensions extensionno setter - successDataOrNull → T?
-
Available on QoraState<
Returns data if Success, null otherwise (ignores previousData).T> , provided by the QoraStateExtensions extensionno setter - updatedAt → DateTime?
-
Available on QoraState<
Gets the timestamp when data was last updated.T> , provided by the QoraStateExtensions extensionno setter
Methods
-
combine<
T2, R> (QoraState< T2> other, R combiner(T data1, T2 data2)) → QoraState<R> -
Available on QoraState<
Combines this state with another state using a combiner function.T> , provided by the QoraStateExtensions extension -
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<
Folds the state into a single value of type R.T> , provided by the QoraStateExtensions extension -
isStale(
Duration threshold) → bool -
Available on QoraState<
Checks if data is stale based on a threshold.T> , provided by the QoraStateExtensions extension -
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<
Maps only if state is Success, otherwise returns the state as-is.T> , provided by the QoraStateExtensions extension -
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<
Returns the data if available, or throws an error.T> , provided by the QoraStateExtensions extension -
toJson(
Map< String, dynamic> dataToJson(T data)) → Map<String, dynamic> -
Available on QoraState<
Serializes this state to JSON.T> , provided by the QoraStateSerializationX extension -
toJsonString(
Map< String, dynamic> dataToJson(T data)) → String -
Available on QoraState<
Serializes this state to a JSON string.T> , provided by the QoraStateSerializationX extension -
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