MutateCallbacks<TData, TVariables, TOnMutateResult> class final Mutations

Callbacks a caller can attach to a single mutate call, on top of the ones in the options — for what only that call site cares about, such as closing a dialog or showing a snack bar.

They run after the cache-wide hooks and the options' callbacks have run and the result has settled, and only while the observer still has a listener: a mutate whose widget has gone still updates the cache, but does not call back into it. A returned future is not awaited, and a throw is reported to the zone rather than failing the mutation.

observer.mutate(
  draft,
  callbacks: MutateCallbacks(
    onSuccess: (task, draft, _) => print('Saved ${task.id}'),
    onError: (error, stackTrace, draft, _) => print('Failed: $error'),
  ),
);
Annotations
  • @immutable

Constructors

MutateCallbacks({OnMutationSuccess<TData, TVariables, TOnMutateResult>? onSuccess, OnMutationError<TVariables, TOnMutateResult>? onError, OnMutationSettled<TData, TVariables, TOnMutateResult>? onSettled})
Creates the callbacks; any of the three may be left unset.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
onError → OnMutationError<TVariables, TOnMutateResult>?
Runs after the options' onError, once retries are spent. No default.
final
onSettled → OnMutationSettled<TData, TVariables, TOnMutateResult>?
Runs after the options' onSettled, on success and error alike, with whichever of data and error applies. No default.
final
onSuccess → OnMutationSuccess<TData, TVariables, TOnMutateResult>?
Runs after the options' onSuccess, with the data, the variables, and what onMutate returned. Like the other two, it is skipped when the observer has stopped listening before the mutation settled. No default.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

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.
inherited