Skip to content

Instantly share code, notes, and snippets.

@boldijar
Created March 13, 2018 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boldijar/6a5918f1947569fef12a08044963b884 to your computer and use it in GitHub Desktop.
Save boldijar/6a5918f1947569fef12a08044963b884 to your computer and use it in GitHub Desktop.
List _cities =
["Cluj-Napoca", "Bucuresti", "Timisoara", "Brasov", "Constanta"];
List<DropdownMenuItem<String>> _dropDownMenuItems;
String _currentCity;
@override
void initState() {
_dropDownMenuItems = getDropDownMenuItems();
_currentCity = _dropDownMenuItems[0].value;
super.initState();
}
// here we are creating the list needed for the DropDownButton
List<DropdownMenuItem<String>> getDropDownMenuItems() {
List<DropdownMenuItem<String>> items = new List();
for (String city in _cities) {
// here we are creating the drop down menu items, you can customize the item right here
// but I'll just use a simple text for this
items.add(new DropdownMenuItem(
value: city,
child: new Text(city)
));
}
return items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment