skip to Main Content

How to change the text of the "OK" button of the popup that shows the dropdown_search package in Flutter, in Multi-selection mode.

See image

DropdownSearch<String>.multiSelection(
    popupProps: PopupPropsMultiSelection.menu(
        showSearchBox: false,
        showSelectedItems: false,
        fit: FlexFit.loose,
    ),
)

Package: https://pub.dev/packages/dropdown_search

I have not found in the documentation any way to change this text.

2

Answers


  1. You can’t modify actual text on that button, but it’s possible to modify button creation.

    This is how button created: source code

    You can provide similar method as validationBuilder parameter to you popupProps. Like this:

    DropdownSearch<String>.multiSelection(
      popupProps: PopupPropsMultiSelection.menu(
        showSearchBox: false,
        showSelectedItems: false,
        fit: FlexFit.loose,
        validationBuilder: (context, items) => Padding(
          padding: EdgeInsets.all(8),
          child: Align(
            alignment: Alignment.centerRight,
            child: ElevatedButton(
              onPressed: () {
                // do something here with items
                // Also you can close dialog here with
                // Navigator.pop(context);
                // default implementation does 2 things:
                // 1. calls onChanged method with items as parameter
                // 2. Closes popup with Navigator.pop(context);
              },
              child: Text("Your text"),
            ),
          ),
        ),
      ),
    );
    

    Pay attention to onPressed – you will have to provide actual logic of closing this menu and manipulate chosen items. I left a comment with suggestion and more or less default implementation.

    Login or Signup to reply.
  2. This code will help you to resolve the issue

    DropdownSearch.multiSelection(
    popupProps: PopupPropsMultiSelection.menu(
    showSearchBox: false,
    showSelectedItems: false,
    fit: FlexFit.loose,
    dialogProps: DialogPropsMultiSelection(
    validationMultiSelectionButton: (context, controller) {
    return ElevatedButton(
    onPressed: () {
    controller.closePopup();
    },
    child: Text("Confirm"),
    );
    },
    ),
    ),
    )

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search