when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String type,
    2. String? description,
    3. String? name,
    4. @JsonKey.new(name: 'in') ParameterLocation? location,
    5. String? scheme,
    6. String? bearerFormat,
    7. String? flow,
    8. String? authorizationUrl,
    9. Map<String, String>? scopes,
    )
)

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 type,  String? description,  String? name, @JsonKey(name: 'in')  ParameterLocation? location,  String? scheme,  String? bearerFormat,  String? flow,  String? authorizationUrl,  Map<String, String>? scopes)  $default,) {final _that = this;
switch (_that) {
case _SecurityScheme():
return $default(_that.type,_that.description,_that.name,_that.location,_that.scheme,_that.bearerFormat,_that.flow,_that.authorizationUrl,_that.scopes);case _:
  throw StateError('Unexpected subclass');

}
}