maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. Map<String, Schema>? schemas,
    2. Map<String, Response>? responses,
    3. Map<String, Parameter>? parameters,
    4. Map<String, Example>? examples,
    5. Map<String, RequestBody>? requestBodies,
    6. Map<String, Header>? headers,
    7. Map<String, SecurityScheme>? securitySchemes,
    8. Map<String, Link>? links,
    9. Map<String, ApiCallback>? callbacks,
    10. Map<String, PathItem>? pathItems,
    )?, {
  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(@_SchemaMapConverter()  Map<String, Schema>? schemas,  Map<String, Response>? responses,  Map<String, Parameter>? parameters,  Map<String, Example>? examples,  Map<String, RequestBody>? requestBodies,  Map<String, Header>? headers,  Map<String, SecurityScheme>? securitySchemes,  Map<String, Link>? links, @_ApiCallbackMapConverter()  Map<String, ApiCallback>? callbacks,  Map<String, PathItem>? pathItems)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Components() when $default != null:
return $default(_that.schemas,_that.responses,_that.parameters,_that.examples,_that.requestBodies,_that.headers,_that.securitySchemes,_that.links,_that.callbacks,_that.pathItems);case _:
  return orElse();

}
}