How to change the text of the "OK" button of the popup that shows the dropdown_search package in Flutter, in Multi-selection mode.
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
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 youpopupProps
. Like this: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.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"),
);
},
),
),
)