InlineMenu<CTX extends Context> class

An inline keyboard menu with callback handlers.

This class provides a fluent API for building inline keyboards where each button can have an associated handler function. When the menu is attached to a bot, the handlers are automatically registered.

Example:

final menu = InlineMenu<Context>()
  .text('Option 1', 'opt1', (ctx) async {
    await ctx.answerCallbackQuery(text: 'You chose option 1!');
  }, style: StyleType.primary)
  .text('Option 2', 'opt2', (ctx) async {
    await ctx.answerCallbackQuery(text: 'You chose option 2!');
  }, style: StyleType.danger)
  .row()
  .url('Visit Website', 'https://example.com');

// Attach to bot
bot.attachMenu(menu);

// Use in message
await ctx.reply('Choose an option:', replyMarkup: menu);
Inheritance
Implemented types
Available extensions

Constructors

InlineMenu({String? name})
Creates a new inline menu.

Properties

$type → String
no setter
forceReply → bool?
Optional. Pass True if the reply interface must be shown to the user, as if they had manually selected the bot's message and tapped 'Reply'. The value of the field can't be changed when the inline keyboard is edited.
no setter
hashCode → int
The hash code for this object.
no setterinherited
inlineKeyboard → List<List<InlineKeyboardButton>>
Array of button rows, each represented by an Array of InlineKeyboardButton objects
no setter
name → String
The unique name/identifier for this menu.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

game(String text, {CallbackGame? game, String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a game button to the current row.
login(String text, String url, {String? forwardText, String? botUsername, bool? requestWriteAccess, String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a login button to the current row.
makeForceReply([bool forceReply = true]) → InlineMenu<CTX>
Makes Telegram clients show the reply interface to the user, as if they had manually selected the bot's message and tapped 'Reply'. The value can't be changed when the inline keyboard is edited.
map<TResult extends Object?>({required TResult forceReply(ForceReply value), required TResult inlineKeyboard(InlineKeyboardMarkup value), required TResult keyboard(ReplyKeyboardMarkup value), required TResult keyboardRemove(ReplyKeyboardRemove value)}) → TResult

Available on ReplyMarkup, provided by the ReplyMarkupPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? forceReply(ForceReply value)?, TResult? inlineKeyboard(InlineKeyboardMarkup value)?, TResult? keyboard(ReplyKeyboardMarkup value)?, TResult? keyboardRemove(ReplyKeyboardRemove value)?}) → TResult?

Available on ReplyMarkup, provided by the ReplyMarkupPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult forceReply(ForceReply value)?, TResult inlineKeyboard(InlineKeyboardMarkup value)?, TResult keyboard(ReplyKeyboardMarkup value)?, TResult keyboardRemove(ReplyKeyboardRemove value)?, required TResult orElse()}) → TResult

Available on ReplyMarkup, provided by the ReplyMarkupPatterns extension

A variant of map that fallback to returning orElse.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pay(String text, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a pay button to the current row.
row() → InlineMenu<CTX>
Starts a new row.
switchInline(String text, String query, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a switch inline query button to the current row.
switchInlineCurrentChat(String text, String query, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a switch inline query current chat button to the current row.
text(String text, String data, MenuHandler<CTX> handler, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a callback button to the current row.
toJson() → Map<String, dynamic>
Serializes this ReplyMarkup to a JSON map.
toReplyMarkup() → ReplyMarkup
Converts this menu to a reply markup that can be sent with messages.
override
toString() → String
A string representation of this object.
override
url(String text, String url, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a URL button to the current row.
webApp(String text, String url, {String? iconCustomEmojiId, StyleType? style}) → InlineMenu<CTX>
Adds a web app button to the current row.

Operators

operator ==(Object other) → bool
The equality operator.
inherited