60';
List<DropdownMenuItem<String>> getALlPackages() {
List<DropdownMenuItem<String>> list = [];
getAllBasePackage().then((value) => _packages = value);
for (ConfiguratorBasePackages package in _packages) {
list.add(DropdownMenuItem<String>(
value: package.description,
child: Text(package.description),
));
}
return list;
}
// Dropdown button method
final _packagesddl = getALlPackages();
if (dropdownValue == "" && _packagesddl.length > 0) {
dropdownValue = _packagesddl.first.value.toString();
}
// Main dropdown button
DropdownButton<String>(
isExpanded: false,
value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down),
onChanged: (String? newValue) {
//print(newValue);
setState(() {
dropdownValue = newValue!;
});
},
onTap: () {},
hint: const Text("Select well"),
items: _packagesddl,
),
),
),
),
When try to set data in drop-down it's not working any solution for this issue??
use unique key in dropdown widget, like key:ValueKey<int>(data.length)
Обсуждают сегодня