Data<T> class
final
Represents a result containing actual data.
Constructors
- Data({required T data, DateTime? lastUpdate})
- Creates a Data, with a last update time set to the current time (i.e. fresh).
- Data.stale(T data)
- Creates a Data, with a last update time set to a value indicating stale data (i.e. needing refresh).
Properties
- data → T
-
The current data.
final
- error → Object?
-
The last error, if any.
no setterinherited
- hasData → bool
-
Checks if the result contains data, regardless of the result type. Note that this is different from isData.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Checks if the current state is Error and the error is a CancelledException.
no setterinherited
- isData → bool
-
Checks if the result is Data. Note that this is different from if this notifier currently contains data
(i.e. hasData).
no setterinherited
- isError → bool
-
Checks if the current state is Error.
no setterinherited
- isInitial → bool
-
Checks if the the result is the Initial loading state.
no setterinherited
- isLoading → bool
-
Checks if the the result is Loading. Note that the initial state (Initial) is also interpreted as a loading state.
no setterinherited
- isLoadingData → bool
-
Checks if the data is currently being loaded, i.e. the current state is Loading but not Initial.
no setterinherited
- isReloading → bool
-
Checks if data is currently being reloaded, i.e. the current state is Loading and hasData.
no setterinherited
- lastUpdate → DateTime
-
The last time the result was updated.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{T? data, DateTime? lastUpdate}) → Result< T> -
Creates a copy of this result with the provided values.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toCancelled(
{T? data, DateTime? lastUpdate}) → Result< T> -
Attempts to convert the result to cancellation Error.
inherited
-
toData(
{T? data, T orElse()?, DateTime? lastUpdate}) → Result< T> -
Attempts to convert the result to Data.
inherited
-
toError(
{Object? error, StackTrace? stackTrace, T? data, DateTime? lastUpdate}) → Result< T> -
Attempts to convert the result to Error.
inherited
-
toFresh(
) → Result< T> -
Creates a fresh copy of this result, meaning lastUpdate will be set to
DateTime.now()
.inherited -
toInitial(
{T? data, DateTime? lastUpdate}) → Result< T> -
Attempts to convert the result to the Initial loading state.
inherited
-
toLoading(
{T? data, DateTime? lastUpdate}) → Result< T> -
Attempts to convert the result to Loading.
inherited
-
toStale(
) → Result< T> -
Creates a stale copy of this result, meaning lastUpdate will be set to zero ms from "epoch".
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited