copyWith method

AsyncPhase<T> copyWith(
  1. T newData
)

A method that copies a phase to create a new instance of the same AsyncPhase subtype with the provided data.

Implementation

AsyncPhase<T> copyWith(T newData) {
  return when(
    initial: (_) => AsyncInitial(newData),
    waiting: (_) => AsyncWaiting(newData),
    complete: (_) => AsyncComplete(newData),
    error: (_, e, s) => AsyncError(data: newData, error: e, stackTrace: s),
  );
}