when<TResult extends Object?> method
- @optionalTypeArgs
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<String> tags, String? summary, String? description, String? operationId, List<Parameter> parameters, RequestBody? requestBody, Map<String, Response> responses, List<SecurityRequirement> security, List<String>? consumes, List<String>? produces, bool? deprecated) $default,) {final _that = this;
switch (_that) {
case _Operation():
return $default(_that.tags,_that.summary,_that.description,_that.operationId,_that.parameters,_that.requestBody,_that.responses,_that.security,_that.consumes,_that.produces,_that.deprecated);case _:
throw StateError('Unexpected subclass');
}
}