when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. @JsonKey.new(name: r'$ref') String? ref,
    2. String? name,
    3. @JsonKey.new(name: 'in') ParameterLocation? location,
    4. String? description,
    5. bool? required,
    6. bool? deprecated,
    7. Schema? schema,
    8. String? type,
    9. String? format,
    10. String? collectionFormat,
    11. Schema? items,
    12. num? maximum,
    13. num? minimum,
    14. bool? explode,
    15. dynamic example,
    )
)

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,  dynamic example)  $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,_that.example);case _:
  throw StateError('Unexpected subclass');

}
}