icemanbsi / searchable_dropdown

MIT License
107 stars 166 forks source link

Setting a preselected value with "value" - selecting other values has no effect #48

Closed giorgio79 closed 4 years ago

giorgio79 commented 4 years ago

Hello,

When I set a preselected value via "value" I am unable to select other values as the selected value is always the preselected one.

                    child: SearchableDropdown.single(
                        value: "USD",
                        items: ["USD", "EUR", "CHF", "HUF"]
giorgio79 commented 4 years ago

PS sorry, I realised we need to set the value before the build function...


var preselected = "USD";

  @override
  Widget build(BuildContext context) {
...
value: preselected.
boungly commented 4 years ago

@giorgio79 can you share your code snippet on selecting preSelectedValue? Because I've did that and doesn't seem to work.

taufiqridha commented 4 years ago

+1 im also having this problem, when using it with class from API to the searchable dropdown @boungly @giorgio79

palicka commented 4 years ago

I've managed to solve it by setting UniqueKey for this widget:

build() {
.....
      return SearchableDropdown.single(
        key: UniqueKey(),
....
}

It's not beautiful solution, but it looks like it's working. Maybe it will help someone...