addButton method

void addButton(
  1. Button button
)

Adds a single button to the message.

Each button is automatically wrapped in an ActionRow.

Example:

builder.addButton(
  MessageButton.primary('confirm', label: 'Confirm'),
);

See also:

  • addButtons to add multiple buttons in a single row
  • Button for button types and options

Implementation

void addButton(Button button) {
  final row = ActionRow(components: [button]);
  _components.add(row);
}