Can’t show the dropdown selected value in Flutter. Check the DropdownButton class , there is a property named value, use your variable _feedCategory in that place, and on your DropdownMenuItem map instead of _feedCategory use category:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | new DropdownButton<FeedCategory>( value: _feedCategory, hint: Text("Select Category"), items: categoriesList.map((FeedCategory category) { return new DropdownMenuItem<FeedCategory>( value: category, child: Text(category.name), ); }).toList(), onChanged: (FeedCategory category) { setState(() { _feedCategory = category; // Problem here too, the element doesn’t show in the dropdown as selected print("Selected: ${_feedCategory.name} (${_feedCategory.id})"); }); }, ), |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.