mapButton static method

Widget mapButton(
  1. Button button,
  2. dynamic callTock(
    1. String text,
    2. String payload
    ), [
  3. dynamic customButton(
    1. Button button
    )?
])

Implementation

static Widget mapButton(
    Button button, Function(String text, String payload) callTock,
    [Function(Button button)? customButton]) {
  switch (button.type) {
    case ButtonsTypes.QUICK_REPLY:
      return QrButton(
        text: button.data['title'],
        onPressed: () {
          callTock(button.data['title'], button.data['payload']);
        },
        key: const Key('value'),
      );
    case ButtonsTypes.POSTBACK_BUTTON:
      return PostbackButton(
        text: button.data[MessagesTypes.TEXT.toText],
        onPressed: () {
          callTock(button.data['title'], button.data['payload']);
        },
        key: const Key('value'),
      );
    case ButtonsTypes.URL_BUTTON:
      return UrlButton(
        text: button.data[MessagesTypes.TEXT.toText],
        url: button.data['url'],
        key: const Key('value'),
      );
    case ButtonsTypes.WIDGET:
      return customButton!(button);
    default:
      return customButton!(button);
  }
}