mutationFnWithContext property
mutationFn with a second argument: the MutationFunctionContext of the
run — the client, meta, the key, what onMutate returned, and a
signal that Mutation.cancel cancels. Instead of mutationFn, never
beside it — both at once fails an assertion at the constructor in a
debug build, and is an ArgumentError when the client resolves the
options in a release build; when set it also wins over a function
registered with setMutationDefaults, which has no context form. No
default.
A second field rather than a second parameter on mutationFn: Dart has
no optional-arity function types, so that would make every
(variables) => … and every tear-off a type error for the sake of the
few functions that want the context. (TanStack Query passes the context
as the function's second argument.)
Implementation
final MutationFnWithContext<TData, TVariables, TOnMutateResult>?
mutationFnWithContext;