toError abstract method
Returns a new state representing an error with the given error
.
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
AsyncState<S> toError(
Object error, {
String? message,
StackTrace? stackTrace,
});