whenOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? whenOrNull<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,
    )?,
})

A variant of when that fallback to returning null

It is equivalent to doing:

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

Implementation

@optionalTypeArgs TResult? whenOrNull<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,}) {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 null;

}
}