InlineKeyboard class abstract
Represents an inline keyboard that appears right next to the message it
belongs to. This is a shortcut for InlineKeyboardMarkup
.
With InlineKeyboard
you can create a keyboard with buttons that can be
pressed inline. This is useful for things like inline menus. For example,
you can create a button that will open a URL when pressed or a button that
will send a callback query to your bot.
// Create a new inline keyboard.
var keyboard = InlineKeyboard()
..addUrl("Open Google", "https://google.com")
..row()
..add("Send a callback query", "callback_query");
// Send the keyboard with the message "Hello World!".
ctx.api.sendMessage(ctx.id, "Hello World!", replyMarkup: keyboard);
- Implemented types
- Annotations
-
- @freezed
Constructors
-
InlineKeyboard.new({@Default([<InlineKeyboardButton>[]]) @JsonKey(name: 'inline_keyboard') List<
List< inlineKeyboard})InlineKeyboardButton> > -
Creates a new InlineKeyboard.
factory
-
InlineKeyboard.fromJson(Map<
String, dynamic> json) -
Creates an InlineKeyboard from JSON
factory
Properties
- $type → String
-
Runtime type
no setter
-
copyWith
→ $InlineKeyboardCopyWith<
InlineKeyboard> -
Create a copy of InlineKeyboard
with the given fields replaced by the non-null parameter values.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inlineKeyboard
→ List<
List< InlineKeyboardButton> > -
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
String text, String data) → InlineKeyboard -
Adds a Inline Keyboard Button with given
text
anddata
to the current row. -
addLogin(
String text, String url, {String? forwardText, String? botUsername, bool? requestWriteAccess}) → InlineKeyboard -
Adds a button with given
text
and login url (url
) -
addUrl(
String text, String url) → InlineKeyboard -
Adds a button with given
text
andurl
. When tapped the given URL is opened. -
addWebApp(
String text, String url) → InlineKeyboard - Adds a button with a URL to your web app that will be launched when the button is pressed.
-
copyText(
String text, {required String copyText}) → InlineKeyboard -
Adds a button which when pressed copies an arbitrary text specified by
copyText
-
game(
String text, {CallbackGame game = const CallbackGame()}) → InlineKeyboard - Adds a callback game button to the keyboard
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pay(
String text, {bool pay = true}) → InlineKeyboard - Adds a Pay Button to the keyboard
-
row(
) → InlineKeyboard - Adds a new row to the current keyboard.
-
switchInlineQuery(
String text, [String query = ""]) → InlineKeyboard -
Adds a button with the given
text
label when tapped prompts user to prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inlinequery
in the input field -
switchInlineQueryChosenChat(
String text, {String query = "", bool? allowUserChats, bool? allowBotChats, bool? allowGroupChats, bool? allowChannelChats}) → InlineKeyboard -
Adds a button with the given
text
label when tapped the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. -
switchInlineQueryCurrentChat(
String text, [String query = ""]) → InlineKeyboard -
Adds a button with the given
text
label when tapped the button will insert the bot's username and the specified inlinequery
in the current chat's input field. -
toJson(
) → Map< String, dynamic> - Converts the InlineKeyboard to JSON
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited