Created
March 13, 2018 17:18
-
-
Save boldijar/6a5918f1947569fef12a08044963b884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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