Keyboard class

The Keyboard class can be used to represent a ReplyKeyboardMarkup. This is an easy method to show a keyboard to the user.

Inheritance

Constructors

Keyboard()
Creates a Keyboard object with no buttons. You can add buttons using the add method.

Properties

hashCode int
The hash code for this object.
no setterinherited
inputFieldPlaceholder String?
Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters
getter/setter pairinherited
isPersistent bool?
Optional. Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.
getter/setter pairinherited
keyboard List<List<KeyboardButton>>
Array of button rows, each represented by an Array of KeyboardButton objects
getter/setter pairinherited
oneTimeKeyboard bool?
Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false.
getter/setter pairinherited
resizeKeyboard bool?
Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selective bool?
Optional. Use this parameter if you want to show the keyboard to specific users only. Targets:
getter/setter pairinherited

Methods

add(KeyboardButton button) Keyboard
Adds a KeyboardButton to show
addPlaceholder(String placeholder) Keyboard
Adds a placeholder value in input field
addRow(List<KeyboardButton> row) Keyboard
Adds a Row of KeyboardButton to the keyboard.
addText(String text) Keyboard
This method adds a new KeyboardButton with the passed text to the end of the row.
makeSelective() Keyboard
Makes the current keyboard selective.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
oneTime() Keyboard
Makes the current Keyboard one time only
persistent() Keyboard
Makes the current keyboard persistent - always shown to the user
requestChat({required String text, required int requestId, bool chatIsChannel = false, bool? chatIsForum, bool? chatHasUsername, bool? chatIsCreated, ChatAdministratorRights? userAdministratorRights, ChatAdministratorRights? botAdministratorRights, bool? botIsMember}) Keyboard
Requests the user to select a chat from the list.
requestContact(String text) Keyboard
Adds a new KeyboardButton tapping which the user's contact is requested with the specified text on it.
requestLocation(String text) Keyboard
Adds a button with given text which requests user's location when tapped.
requestUser({required String text, required int requestId, bool? userIsBot, bool? userIsPremium}) Keyboard
Requests the user to select a user from the list.
resized() Keyboard
Makes the current Keyboard resized.
row() Keyboard
Adds a new row to the current keyboard.
text(String text) Keyboard
Shorthand method to add a text button to the end row. This is the same as addText call.
texts(List<String> texts) Keyboard
Adds multiple text buttons to the current row.
toJson() Map<String, dynamic>
Converts a ReplyKeyboardMarkup object to a json String
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

remove({bool? selective}) ReplyKeyboardRemove
This method can be used to remove the Keyboard that is already attached.