maybeMap<TResult extends Object?> method
- @optionalTypeArgs
- TResult plain(
- RichTextPlain value
- TResult collection(
- RichTextCollection value
- TResult bold(
- RichTextBold value
- TResult italic(
- RichTextItalic value
- TResult underline(
- RichTextUnderline value
- TResult strikethrough(
- RichTextStrikethrough value
- TResult spoiler(
- RichTextSpoiler value
- TResult dateTime(
- RichTextDateTime value
- TResult textMention(
- RichTextTextMention value
- TResult subscript(
- RichTextSubscript value
- TResult superscript(
- RichTextSuperscript value
- TResult marked(
- RichTextMarked value
- TResult code(
- RichTextCode value
- TResult customEmoji(
- RichTextCustomEmoji value
- TResult mathematicalExpression(
- RichTextMathematicalExpression value
- TResult url(
- RichTextUrl value
- TResult emailAddress(
- RichTextEmailAddress value
- TResult phoneNumber(
- RichTextPhoneNumber value
- TResult bankCardNumber(
- RichTextBankCardNumber value
- TResult mention(
- RichTextMention value
- TResult hashtag(
- RichTextHashtag value
- TResult cashtag(
- RichTextCashtag value
- TResult botCommand(
- RichTextBotCommand value
- TResult anchor(
- RichTextAnchor value
- TResult anchorLink(
- RichTextAnchorLink value
- TResult reference(
- RichTextReference value
- TResult referenceLink(
- RichTextReferenceLink value
- 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(RichTextPlain value)? plain,
TResult Function(RichTextCollection value)? collection,
TResult Function(RichTextBold value)? bold,
TResult Function(RichTextItalic value)? italic,
TResult Function(RichTextUnderline value)? underline,
TResult Function(RichTextStrikethrough value)? strikethrough,
TResult Function(RichTextSpoiler value)? spoiler,
TResult Function(RichTextDateTime value)? dateTime,
TResult Function(RichTextTextMention value)? textMention,
TResult Function(RichTextSubscript value)? subscript,
TResult Function(RichTextSuperscript value)? superscript,
TResult Function(RichTextMarked value)? marked,
TResult Function(RichTextCode value)? code,
TResult Function(RichTextCustomEmoji value)? customEmoji,
TResult Function(RichTextMathematicalExpression value)?
mathematicalExpression,
TResult Function(RichTextUrl value)? url,
TResult Function(RichTextEmailAddress value)? emailAddress,
TResult Function(RichTextPhoneNumber value)? phoneNumber,
TResult Function(RichTextBankCardNumber value)? bankCardNumber,
TResult Function(RichTextMention value)? mention,
TResult Function(RichTextHashtag value)? hashtag,
TResult Function(RichTextCashtag value)? cashtag,
TResult Function(RichTextBotCommand value)? botCommand,
TResult Function(RichTextAnchor value)? anchor,
TResult Function(RichTextAnchorLink value)? anchorLink,
TResult Function(RichTextReference value)? reference,
TResult Function(RichTextReferenceLink value)? referenceLink,
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case RichTextPlain() when plain != null:
return plain(_that);
case RichTextCollection() when collection != null:
return collection(_that);
case RichTextBold() when bold != null:
return bold(_that);
case RichTextItalic() when italic != null:
return italic(_that);
case RichTextUnderline() when underline != null:
return underline(_that);
case RichTextStrikethrough() when strikethrough != null:
return strikethrough(_that);
case RichTextSpoiler() when spoiler != null:
return spoiler(_that);
case RichTextDateTime() when dateTime != null:
return dateTime(_that);
case RichTextTextMention() when textMention != null:
return textMention(_that);
case RichTextSubscript() when subscript != null:
return subscript(_that);
case RichTextSuperscript() when superscript != null:
return superscript(_that);
case RichTextMarked() when marked != null:
return marked(_that);
case RichTextCode() when code != null:
return code(_that);
case RichTextCustomEmoji() when customEmoji != null:
return customEmoji(_that);
case RichTextMathematicalExpression() when mathematicalExpression != null:
return mathematicalExpression(_that);
case RichTextUrl() when url != null:
return url(_that);
case RichTextEmailAddress() when emailAddress != null:
return emailAddress(_that);
case RichTextPhoneNumber() when phoneNumber != null:
return phoneNumber(_that);
case RichTextBankCardNumber() when bankCardNumber != null:
return bankCardNumber(_that);
case RichTextMention() when mention != null:
return mention(_that);
case RichTextHashtag() when hashtag != null:
return hashtag(_that);
case RichTextCashtag() when cashtag != null:
return cashtag(_that);
case RichTextBotCommand() when botCommand != null:
return botCommand(_that);
case RichTextAnchor() when anchor != null:
return anchor(_that);
case RichTextAnchorLink() when anchorLink != null:
return anchorLink(_that);
case RichTextReference() when reference != null:
return reference(_that);
case RichTextReferenceLink() when referenceLink != null:
return referenceLink(_that);
case _:
return orElse();
}
}