I have an implementation of this package as:
CustomDropdown.searchRequest(
items: [some items],
futureRequest: futureRequest,
hintText: 'Search something...',
controller: _controllerForText,
onChanged: (selected) {
//some logic...
},
),
It work perfect, but...
How can I specify the selected item, for example, when editing some model, I start the view with every field fill with the current value, how do I put the value corresponding to this dropdown.
Or if I have one dropdown that depend on other, B depend on A, when I select a item in A, B is updated with the info, and I update the view, but if I update the view A loose the selected item.
In defaults dropdown, there is a property 'value' with this function, what is the equivalent of this property in this package?
This is the one how worked for my:
DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: Text(
'Select type',
style: TextStyle(
fontSize: 14,
color: Theme.of(context).hintColor,
),
),
items: items
.map(
(item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
),
)
.toList(),
value: initialValue, //this property is what I need
onChanged: (value) {
//some logic
},
),
)