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