Relative Content

Tag Archive for flutterdrop-down-menu

dropdown_search flutter search functionality not working

DropdownSearch<ProductModel>( asyncItems: (String filter) => getData(filter), itemAsString: (ProductModel u) => u.name, onChanged: (ProductModel? data) { instcatname = data?.name; instcatid = data?.id; calibprov.SaveInstcatid(data!.id); calibprov.Saveinstcatname(data.name); print(“instcatnameis${calibprov.instcatname}”); print(“instcatidis${calibprov.instcatid}”); }, dropdownDecoratorProps: DropDownDecoratorProps( dropdownSearchDecoration: InputDecoration( labelText: calibprov.instcatname ?? “Instrument Category”, hintText: “Search”, ), ), ), Future<List<ProductModel>> getData(String filter) async { await Provider.of<CaliberationProvider>(context, listen: false).FetchInstCategory(); List<ProductModel> instcategory = Provider.of<CaliberationProvider>(context, listen: false).instcategory; […]

how to get a string from a flutter dropdownmenu model

I hava a dropdownmenu that displays the list of States from a get endpoint in a dropdown, the states has other attributes like id and name and I have been able to display them(i.e the state name) in a dropdownmenu. The issue is that I want to display the name of the selected state when a user select on it using the value attribute but I can’t be able to achieve that because my dropdownmenu takes a StateData model while I wanted to display a string(the selected state’s name) as the value. It’s telling me that the value is expecting an object of type StateData while I am trying to provide a string to it. Please how can I be able to display the name of the selected state as a string using the value attributes?

how to retrieve a list of response from the model and display it in a dropdownbutton2 in flutter

I was using this plugin nigerian_states_and_lga: to display a list of states and their local governments in my app until today that the backend team decided to come up with their own API that they developed for that and I am finding it difficult to implement it. What I did was that when you select on a state, another dropdownbutton will display the local government based on the state that was selected. Now they want me to do the same thing using their own API. They want the first dropdownbutton to display a list of all the states as contained in their API and when the user select on any state, the Id of that state should be picked and then used in querying another endpoint that returns a list of local government based on the state Id that was passed and display the list of those local government immediately in the seconde dropdownbutton.
The model class here is the format for the API response and this dropdownbutton2 is the one that I did with the plugins so I am looking for the way to substitute this with the new approach that they demand.