copyWithPrevious method
Clone an AsyncValue, merging it with previous
.
When doing so, the resulting AsyncValue can contain the information about multiple state at once. For example, this allows an AsyncError to contain a value, or even AsyncLoading to contain both a value and an error.
The optional isRefresh
flag (true by default) represents whether the
provider rebuilt by Ref.refresh/Ref.invalidate (if true)
or instead by Ref.watch (if false).
This changes the default behavior of when and sets the isReloading
/
isRefreshing
flags accordingly.
Implementation
@override
AsyncError<T> copyWithPrevious(
AsyncValue<T> previous, {
bool isRefresh = true,
}) {
return AsyncError._(
error,
stackTrace: stackTrace,
isLoading: isLoading,
value: previous.valueOrNull,
hasValue: previous.hasValue,
);
}