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!');
})
.text('Option 2', 'opt2', (ctx) async {
await ctx.answerCallbackQuery(text: 'You chose option 2!');
})
.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
-
- Object
- TeleverseMenu<
CTX> - InlineMenu
- Implemented types
Constructors
- InlineMenu.new({String? name})
- Creates a new inline menu.
Properties
- $type → String
-
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}) → InlineMenu< CTX> - Adds a game button to the current row.
-
login(
String text, String url, {String? forwardText, String? botUsername, bool? requestWriteAccess}) → InlineMenu< CTX> - Adds a login button to the current row.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pay(
String text) → InlineMenu< CTX> - Adds a pay button to the current row.
-
row(
) → InlineMenu< CTX> - Starts a new row.
-
switchInline(
String text, String query) → InlineMenu< CTX> - Adds a switch inline query button to the current row.
-
switchInlineCurrentChat(
String text, String query) → InlineMenu< CTX> - Adds a switch inline query current chat button to the current row.
-
text(
String text, String data, MenuHandler< CTX> handler) → 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) → InlineMenu< CTX> - Adds a URL button to the current row.
-
webApp(
String text, String url) → InlineMenu< CTX> - Adds a web app button to the current row.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited