createButtonMessage static method

InteractiveMessage createButtonMessage({
  1. required String recipient,
  2. required String bodyText,
  3. required List<Button> buttons,
  4. String? headerText,
  5. String? footerText,
})

Creates a button-based interactive message.

recipient is the recipient's phone number. bodyText is the main message text. buttons is the list of buttons to display. headerText is optional text for the header. footerText is optional text for the footer.

Implementation

static InteractiveMessage createButtonMessage({
  required String recipient,
  required String bodyText,
  required List<Button> buttons,
  String? headerText,
  String? footerText,
}) {
  return InteractiveMessage(
    recipient: recipient,
    interactiveType: InteractiveType.button,
    body: BodyComponent(text: bodyText),
    action: ButtonActionComponent(buttons: buttons),
    header: headerText != null ? HeaderComponent(text: headerText) : null,
    footer: footerText != null ? FooterComponent(text: footerText) : null,
  );
}