copyWith method

AsyncPhase<T> copyWith(
  1. T newData
)

A method that copy a phase to create a new phase with new data.

The returned phase has the same type as that of the original phase this method was called on.

Implementation

AsyncPhase<T> copyWith(T newData) {
  return switch (this) {
    AsyncInitial() => AsyncInitial(newData),
    AsyncWaiting() => AsyncWaiting(newData),
    AsyncComplete() => AsyncComplete(newData),
    AsyncError() =>
      AsyncError(data: newData, error: _error, stackTrace: _stackTrace),
  };
}