maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String? contentType,
    2. Map<String, Header> headers,
    3. String? style,
    4. bool? explode,
    5. bool? allowReserved,
    6. @JsonKey.new(name: r'$ref') String? ref,
    )?, {
  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( String? contentType,  Map<String, Header> headers,  String? style,  bool? explode,  bool? allowReserved, @JsonKey(name: r'$ref')  String? ref)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Encoding() when $default != null:
return $default(_that.contentType,_that.headers,_that.style,_that.explode,_that.allowReserved,_that.ref);case _:
  return orElse();

}
}