icemanbsi / searchable_dropdown

MIT License
107 stars 166 forks source link

Searchable dropDown value is changing only once in stateful widget in flutter #42

Closed Robinp1011 closed 4 years ago

Robinp1011 commented 4 years ago

Hi, my problem is when i try to select value in searchable dropdown second time then it is not changing remaining same as that in case of ist change , but i can select different value after clearing the value .

code:

SearchableDropdown.single( items: widget.projectList.cast()

                                      .map<DropdownMenuItem<String>>((String value) {
                                    return DropdownMenuItem<String>(
                                      value: value,
                                      child: Text(value),

                                    );
                                  })
                                      .toList(),
                                  value: dropDownValue,
                                  hint: "Select one",
                                  searchHint: "Select one",
                                  onChanged: (value) {
                                    setState(() {
                                      dropDownValue = value;
                                    });
                                  },
                                  isExpanded: true,
                                  // label: "Select Project",
                                  selectedValueWidgetFn: (item) {
                                    return Container(
                                        transform: Matrix4.translationValues(-10,0,0),
                                        alignment: Alignment.centerLeft,
                                        child: (Text(item.toString())));
                                  },

                                  // style: Theme.of(context).textTheme.title,
                               //   displayClearIcon: false,

                                );

and this code is working perfect in stateless widget but problem coming in stateful widget.

i will be thankful for your solution

lcuis commented 4 years ago

Hello @Robinp1011 ,

Thanks for raising this issue.

Could you please share an example with a stateful widget?

lcuis commented 4 years ago

Maybe this is solved by PR #26 that is merged but not published to pub.dev ? If so, you may want to give a try at an alternative plugin that also has this fixed but is published to pub.dev : search_choices .

Robinp1011 commented 4 years ago

Maybe this is solved by PR #26 that is merged but not published to pub.dev ? If so, you may want to give a try at an alternative plugin that also has this fixed but is published to pub.dev : search_choices .

Thanks sir , this plugin is working perfect in stateful widget. Thanks for your help.

lcuis commented 4 years ago

Great, thanks for the confirmation @Robinp1011 , enjoy!