convert<U> method
A method that creates a new object of the same AsyncPhase subtype with a different generic type based on the phase that this method is called on.
Implementation
AsyncPhase<U> convert<U>(U Function(T?) converter) {
return when(
initial: (data) => AsyncInitial(converter(data)),
waiting: (data) => AsyncWaiting(converter(data)),
complete: (data) => AsyncComplete(converter(data)),
error: (data, e, s) =>
AsyncError(data: converter(data), error: e, stackTrace: s),
);
}