maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
  1. TResult cookie(
    1. String? name,
    2. String? description,
    3. bool? required,
    4. bool? deprecated,
    5. String? style,
    6. bool? explode,
    7. bool? allowReserved,
    8. String? example,
    9. Schema schema,
    10. String? ref,
    )?,
  2. TResult header(
    1. String? name,
    2. String? description,
    3. bool? required,
    4. bool? deprecated,
    5. String? style,
    6. bool? explode,
    7. bool? allowReserved,
    8. String? example,
    9. Schema schema,
    10. String? ref,
    )?,
  3. TResult query(
    1. String? name,
    2. String? description,
    3. bool? required,
    4. bool? deprecated,
    5. String? style,
    6. bool? explode,
    7. bool? allowReserved,
    8. String? example,
    9. Schema schema,
    10. String? ref,
    )?,
  4. TResult path(
    1. String? name,
    2. String? description,
    3. bool? deprecated,
    4. String? style,
    5. bool? explode,
    6. bool? allowReserved,
    7. String? example,
    8. Schema? schema,
    9. String? ref,
    )?,
  5. 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( String? name,  String? description,  bool? required,  bool? deprecated,  String? style,  bool? explode,  bool? allowReserved,  String? example,  Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter()  String? ref)?  cookie,TResult Function( String? name,  String? description,  bool? required,  bool? deprecated,  String? style,  bool? explode,  bool? allowReserved,  String? example,  Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter()  String? ref)?  header,TResult Function( String? name,  String? description,  bool? required,  bool? deprecated,  String? style,  bool? explode,  bool? allowReserved,  String? example,  Schema schema, @JsonKey(name: '\$ref')@_ParamRefConverter()  String? ref)?  query,TResult Function( String? name,  String? description,  bool? deprecated,  String? style,  bool? explode,  bool? allowReserved,  String? example,  Schema? schema, @JsonKey(name: '\$ref')@_ParamRefConverter()  String? ref)?  path,required TResult orElse(),}) {final _that = this;
switch (_that) {
case ParameterCookie() when cookie != null:
return cookie(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterHeader() when header != null:
return header(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterQuery() when query != null:
return query(_that.name,_that.description,_that.required,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case ParameterPath() when path != null:
return path(_that.name,_that.description,_that.deprecated,_that.style,_that.explode,_that.allowReserved,_that.example,_that.schema,_that.ref);case _:
  return orElse();

}
}