maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<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,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<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,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Parameter() when $default != null:
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 _:
  return orElse();

}
}