DropdownButton(
value: currentItem,
items: items
.map<DropdownMenuItem<String>>(
(e) => DropdownMenuItem(
value: e,
child: Text(e),
),
)
.toList(),
onChanged: (String? value) => setState(
() {
if (value != null) currentItem = value;
},
),
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
DropdownButton(
value: currentItem,
items: items
.map<DropdownMenuItem<String>>(
(e) => DropdownMenuItem(
value: e,
child: Text(e),
),
)
.toList(),
onChanged: (String? value) => setState(
() {
if (value != null) currentItem = value;
},
),
),
Text(currentItem),
],
),
)
List<DropdownMenuItem<String>> getDropdownItems() {
List<DropdownMenuItem<String>> dropDownItems = [];
for (String currency in currenciesList) {
var newDropdown = DropdownMenuItem(
child: Text(currency),
value: currency,
);
dropDownItems.add(newDropdown);
}
return dropDownItems;
}