maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>({
- TResult requestCancelled()?,
- TResult unauthorisedRequest()?,
- TResult unauthorisedRequestApple()?,
- TResult badRequest()?,
- TResult notFound(
- String reason
- TResult methodNotAllowed()?,
- TResult notAcceptable()?,
- TResult requestTimeout()?,
- TResult sendTimeout()?,
- TResult conflict()?,
- TResult internalServerError()?,
- TResult notImplemented()?,
- TResult noInternetConnection()?,
- TResult formatException()?,
- TResult unableToProcess()?,
- TResult defaultError(
- String error
- TResult unexpectedError()?,
- TResult otpExpired()?,
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? requestCancelled,TResult Function()? unauthorisedRequest,TResult Function()? unauthorisedRequestApple,TResult Function()? badRequest,TResult Function( String reason)? notFound,TResult Function()? methodNotAllowed,TResult Function()? notAcceptable,TResult Function()? requestTimeout,TResult Function()? sendTimeout,TResult Function()? conflict,TResult Function()? internalServerError,TResult Function()? notImplemented,TResult Function()? serviceUnavailable,TResult Function()? noInternetConnection,TResult Function()? formatException,TResult Function()? unableToProcess,TResult Function( String error)? defaultError,TResult Function()? unexpectedError,TResult Function()? otpExpired,required TResult orElse(),}) {final _that = this;
switch (_that) {
case RequestCancelled() when requestCancelled != null:
return requestCancelled();case UnauthorisedRequest() when unauthorisedRequest != null:
return unauthorisedRequest();case UnauthorisedRequestApple() when unauthorisedRequestApple != null:
return unauthorisedRequestApple();case BadRequest() when badRequest != null:
return badRequest();case NotFound() when notFound != null:
return notFound(_that.reason);case MethodNotAllowed() when methodNotAllowed != null:
return methodNotAllowed();case NotAcceptable() when notAcceptable != null:
return notAcceptable();case RequestTimeout() when requestTimeout != null:
return requestTimeout();case SendTimeout() when sendTimeout != null:
return sendTimeout();case Conflict() when conflict != null:
return conflict();case InternalServerError() when internalServerError != null:
return internalServerError();case NotImplemented() when notImplemented != null:
return notImplemented();case ServiceUnavailable() when serviceUnavailable != null:
return serviceUnavailable();case NoInternetConnection() when noInternetConnection != null:
return noInternetConnection();case FormatException() when formatException != null:
return formatException();case UnableToProcess() when unableToProcess != null:
return unableToProcess();case DefaultError() when defaultError != null:
return defaultError(_that.error);case UnexpectedError() when unexpectedError != null:
return unexpectedError();case OtpExpired() when otpExpired != null:
return otpExpired();case _:
return orElse();
}
}