copyWith method
MutationState<TData, TVariables, TOnMutateResult>
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,
A copy with the given fields replaced. null leaves a field as it was;
the clear* flags are how a field is set back to nothing.
Implementation
MutationState<TData, TVariables, TOnMutateResult> 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>(
status: status ?? this.status,
hasData: clearData ? false : (hasData ?? this.hasData),
// `data` and `hasData` travel together, as on `QueryState`: with
// `hasData: true` the value is authoritative even when it is `null`.
data: clearData ? null : (hasData == true ? data : (data ?? this.data)),
error: clearError ? null : (error ?? this.error),
errorStackTrace:
clearError ? null : (errorStackTrace ?? this.errorStackTrace),
variables: variables ?? this.variables,
hasVariables: hasVariables ?? this.hasVariables,
onMutateResult: onMutateResult ?? this.onMutateResult,
failureCount: failureCount ?? this.failureCount,
failureReason:
clearFailureReason ? null : (failureReason ?? this.failureReason),
isPaused: isPaused ?? this.isPaused,
submittedAt: submittedAt ?? this.submittedAt,
);