MutationState<TData, TVariables, TOnMutateResult> class
final
A mutation's state at one point in time: its status, the variables of the current or last run, its data or error, and retry bookkeeping.
Read it from Mutation.state, or select from it across the cache with a
MutationStateObserver. A persistence layer builds one to restore an
offline mutation through MutationCache.build. Value equality (stack
traces left out), so a restored state compares equal to the one written.
- Annotations
Constructors
- MutationState({MutationStatus status = MutationStatus.idle, bool hasData = false, TData? data, Object? error, StackTrace? errorStackTrace, TVariables? variables, bool hasVariables = false, TOnMutateResult? onMutateResult, int failureCount = 0, Object? failureReason, bool isPaused = false, DateTime? submittedAt})
-
Creates a state; with no arguments, the idle state a fresh mutation
starts in.
const
Properties
- data → TData?
-
What the last successful run returned; meaningful only while hasData.
final
- error → Object?
-
Why the last run failed;
nullunless status iserror.final - errorStackTrace → StackTrace?
-
The stack trace of error;
nullunless status iserror.final - failureCount → int
-
How many attempts of the current run have failed. Reset on success;
bumped once more when the run settles in error.
final
- failureReason → Object?
-
What the last failed attempt threw, kept while retries continue.
final
- hasData → bool
-
Whether data is authoritative. Travels with data so that a mutation
whose function legitimately returned
nullstill reads as having data.final - hashCode → int
-
The hash code for this object.
no setteroverride
- hasVariables → bool
-
Whether variables have been set by a run — a
nullvariables value is a real value once this is true.final - isPaused → bool
-
Whether the run is parked, waiting for the network, the foreground, or
its scope.
final
- onMutateResult → TOnMutateResult?
-
What
onMutatereturned for the run in flight or last finished; handed to the success, error and settled callbacks.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → MutationStatus
-
Where the mutation is in its life; see MutationStatus. Default
MutationStatus.idle.
final
- submittedAt → DateTime?
-
When the current (or last) run was submitted — the moment
mutatewas called, read frompackage:clock.nullbefore the first run.final - variables → TVariables?
-
The variables of the run in flight or last finished — what optimistic UI
reads while the mutation is pending.
final
Methods
-
copyWith(
{MutationStatus? status, bool? hasData, TData? data, Object? error, StackTrace? errorStackTrace, TVariables? variables, bool? hasVariables, TOnMutateResult? onMutateResult, int? failureCount, Object? failureReason, bool? isPaused, DateTime? submittedAt, bool clearData = false, bool clearError = false, bool clearFailureReason = false}) → MutationState< TData, TVariables, TOnMutateResult> -
A copy with the given fields replaced.
nullleaves a field as it was; theclear*flags are how a field is set back to nothing. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override