Search
 
SCRIPT & CODE EXAMPLE
 

DART

how to use future Dropownitem list in flutter

new DropdownButtonHideUnderline(
              child: new FutureBuilder<List<BranchItems>>(
                future: new BranchService().fetchBranchItems(),
                builder: (context, snapshot) {
                  if (snapshot.hasError) {
                    return new Container();
                  } else if (snapshot.hasData) {
                    list.clear();
                    //listItemNames.clear();
                    dropDownItemsMap = new Map();

                    snapshot.data.forEach((branchItem) {
                      //listItemNames.add(branchItem.itemName);
                      int index = snapshot.data.indexOf(branchItem);
                      dropDownItemsMap[index] = branchItem;

                      list.add(new DropdownMenuItem(
                          child: new DropDownItem(
                              image: Image.network(branchItem.itemPicture),
                              text: branchItem.itemName),
                          value: index));
                    });

                    return DropdownButton(
                      items: list,
                      onChanged: (int selected) {
                        _selectedItem = list[selected].value;
                        setState(() {
                          selectedItemName =
                              dropDownItemsMap[_selectedItem].itemName;
                        });
                      },
                      hint: new Text(
                        selectedItemName,
                        style: new TextStyle(color: Colors.blue),
                      ),
                    );
                  } else {
                    return CircularProgressIndicator();
                  }
                },
              ),
            ),
Comment

PREVIOUS NEXT
Code Example
Dart :: how to hide status bar phone flutter 
Dart :: flutter delete directory 
Dart :: flutter getx dialog 
Dart :: how to rename file in flutter 
Dart :: print an object dart 
Dart :: what is interface in dart 
Dart :: loop map flutter 
Dart :: dart find in array 
Dart :: flutter periodic timer 
Dart :: flutter pageview show next page 
Dart :: convert datetime to TZDateTimeflutter 
Dart :: flutter encode 
Dart :: flutter how to create text with line on bot 
Dart :: change color icon tabbar flutter 
Dart :: how to create random gradient in flutter 
Dart :: what is late in dart 
Dart :: dart anonymous function in forEach 
Dart :: flutter radial gradient with alignment 
Dart :: hive dart type adapter 
Dart :: flutter dollar sign interpolation 
Dart :: how to convert string into integer in flutter 
Dart :: dartlang console plugin 
Dart :: dart add list to list 
Swift :: settimeout in swift 
Swift :: show alert with textfield swift 
Swift :: unrecognized font family Helvetica-Regular 
Swift :: get request swift 
Swift :: round up swift 
Swift :: change button text in swift 
Swift :: swift post request 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =