toError method

  1. @override
AsyncState<S> toError(
  1. Object error, {
  2. String? message,
  3. StackTrace? stackTrace,
})
override

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),
  );
}