toError method
Returns a new AsyncState with the given error information.
error
is the error object or exception.
message
is an optional error message.
stackTrace
is an optional stack trace for debugging.
Use this to transition to an error state from any other state.
Implementation
@override
AsyncState<S> toError(
Object error, {
String? message,
StackTrace? stackTrace,
}) {
return _copyWith(
status: AsyncStatus.error,
errorState: ErrorState(error, message: message, stackTrace: stackTrace),
);
}