when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String? description,
    2. bool? required,
    3. bool? deprecated,
    4. String? style,
    5. bool? explode,
    6. Schema? schema,
    7. dynamic example,
    8. Map<String, Example>? examples,
    9. Map<String, MediaType>? content,
    10. @JsonKey.new(name: r'$ref') String? ref,
    )
)

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( String? description,  bool? required,  bool? deprecated,  String? style,  bool? explode,  Schema? schema,  dynamic example,  Map<String, Example>? examples,  Map<String, MediaType>? content, @JsonKey(name: r'$ref')  String? ref)  $default,) {final _that = this;
switch (_that) {
case _Header():
return $default(_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.schema,_that.example,_that.examples,_that.content,_that.ref);case _:
  throw StateError('Unexpected subclass');

}
}