Nikita
Nikita

Reputation: 765

Change selected Items style || multiselect dependency Flutter

The Question sounds dumb, but I cant figure out how to change the style of the selected Items in the Multiselect dependency.

My Widget looks like this:

DropDownMultiSelect(
    hintStyle: const TextStyle(color: Colors.black),
    selectedValues: gewaehlteArten,
    whenEmpty: "",
    options: arten,
    onChanged: (List<String> specificArten) {
      setArten(arten: specificArten);
    });

What can I do?

Here an additional picture:

enter image description here

I want to change the color to any other except of white ;)

Upvotes: 0

Views: 437

Answers (1)

Praveena
Praveena

Reputation: 6941

DropDownMultiSelect has prop called menuItembuilder and use that and you can change style based on currently selected values

DropDownMultiSelect(
hintStyle: const TextStyle(color: Colors.black),
selectedValues: gewaehlteArten,
whenEmpty: "",
options: arten,
menuItembuilder: (option){
  if(gewaehlteArten.contains(option) return YOUR_SELECTED_WIDGET;
  return NORMAL_WIDGET;
},
onChanged: (List<String> specificArten) {
  setArten(arten: specificArten);
});

You can also use childBuilder to make menu completely custom.

Upvotes: 1

Related Questions