maybeMap<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
  1. TResult plain(
    1. OutputFormat_Plain value
    )?,
  2. TResult markdown(
    1. OutputFormat_Markdown value
    )?,
  3. TResult djot(
    1. OutputFormat_Djot value
    )?,
  4. TResult html(
    1. OutputFormat_Html value
    )?,
  5. TResult json(
    1. OutputFormat_Json value
    )?,
  6. TResult docTags(
    1. OutputFormat_DocTags value
    )?,
  7. TResult custom(
    1. OutputFormat_Custom value
    )?,
  8. required TResult orElse(),
})

A variant of map that fallback to returning orElse.

It is equivalent to doing:

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

Implementation

@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( OutputFormat_Plain value)?  plain,TResult Function( OutputFormat_Markdown value)?  markdown,TResult Function( OutputFormat_Djot value)?  djot,TResult Function( OutputFormat_Html value)?  html,TResult Function( OutputFormat_Json value)?  json,TResult Function( OutputFormat_DocTags value)?  docTags,TResult Function( OutputFormat_Custom value)?  custom,required TResult orElse(),}){
final _that = this;
switch (_that) {
case OutputFormat_Plain() when plain != null:
return plain(_that);case OutputFormat_Markdown() when markdown != null:
return markdown(_that);case OutputFormat_Djot() when djot != null:
return djot(_that);case OutputFormat_Html() when html != null:
return html(_that);case OutputFormat_Json() when json != null:
return json(_that);case OutputFormat_DocTags() when docTags != null:
return docTags(_that);case OutputFormat_Custom() when custom != null:
return custom(_that);case _:
  return orElse();

}
}