maybeMap<TResult extends Object?> method
- @optionalTypeArgs
- TResult default_(
- BotCommandScopeDefault value
- TResult allPrivateChats(
- BotCommandScopeAllPrivateChats value
- TResult allGroupChats(
- BotCommandScopeAllGroupChats value
- TResult allChatAdministrators(
- BotCommandScopeAllChatAdministrators value
- TResult chat(
- BotCommandScopeChat value
- TResult chatAdministrators(
- BotCommandScopeChatAdministrators value
- TResult chatMember(
- BotCommandScopeChatMember 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(BotCommandScopeDefault value)? default_,
TResult Function(BotCommandScopeAllPrivateChats value)? allPrivateChats,
TResult Function(BotCommandScopeAllGroupChats value)? allGroupChats,
TResult Function(BotCommandScopeAllChatAdministrators value)?
allChatAdministrators,
TResult Function(BotCommandScopeChat value)? chat,
TResult Function(BotCommandScopeChatAdministrators value)?
chatAdministrators,
TResult Function(BotCommandScopeChatMember value)? chatMember,
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case BotCommandScopeDefault() when default_ != null:
return default_(_that);
case BotCommandScopeAllPrivateChats() when allPrivateChats != null:
return allPrivateChats(_that);
case BotCommandScopeAllGroupChats() when allGroupChats != null:
return allGroupChats(_that);
case BotCommandScopeAllChatAdministrators()
when allChatAdministrators != null:
return allChatAdministrators(_that);
case BotCommandScopeChat() when chat != null:
return chat(_that);
case BotCommandScopeChatAdministrators() when chatAdministrators != null:
return chatAdministrators(_that);
case BotCommandScopeChatMember() when chatMember != null:
return chatMember(_that);
case _:
return orElse();
}
}