Question:
Output in Working Condtion Hello Flutter/Dart Programmers, I’m new in Flutter. below code about Dropdown is working without API, but i wants API data to display in Dropdown list…. i need helpAnswer:
UseFutureBuilder
to build widgets which requires Future
value.You can return new list of
DropDownMenuIems
from your getAllCategory()
method Instead of updating old Items.
Like:getAllCategory()
as future of FutureBuilder
. FutureBuilder
will build different widgets according to the provided Future
. you can return CircularProgressIndicator
until future doesn’t have value. After getting your DropDownMenuItems
you can return your DropDownMenu
. Like:If you have better answer, please add a comment about this, thank you!