when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default()
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(@JsonKey(name: r'$ref') String? ref, String? name, @JsonKey(name: 'in') ParameterLocation? location, String? description, bool? required, bool? deprecated, Schema? schema, String? type, String? format, String? collectionFormat, Schema? items, num? maximum, num? minimum, bool? explode) $default,) {final _that = this;
switch (_that) {
case _Parameter():
return $default(_that.ref,_that.name,_that.location,_that.description,_that.required,_that.deprecated,_that.schema,_that.type,_that.format,_that.collectionFormat,_that.items,_that.maximum,_that.minimum,_that.explode);case _:
throw StateError('Unexpected subclass');
}
}