简体   繁体   中英

Flutter Error while dropDownButton Select

Hi i am new in Flutter App developer,so please help. When first time app start then working fine but during select dorpdown value select then getting error using GridView.count在此处输入图片说明 .

   ProductsModel values = snapshot.data;
   List<Product> results = values.data;
    List<List<Inventory>> productList=values.data[index].inventory;
    List<Inventory> productInventoryList=productList[0];       
                  
                         child: DropdownButton<Inventory>(
                          items: productInventoryList.map((proInventory) => 
                          DropdownMenuItem<Inventory>(
                            child: Text(proInventory.label+" "+proInventory.weight),
                            value: proInventory,
                          )).toList(),
                          onChanged: (Inventory value) {
                            setState(() {
                              productInventoryDropDown = value;
                            });
                          },
                          isExpanded: false,
                          value: productInventoryDropDown,
                          hint: productInventoryList[0].weight == null ? Text('Select Weight') : 
                              Text(productInventoryList[0].label+" "+productInventoryList[0].weight,
                            style: TextStyle(color: Colors.black),
                          ),
                        ),

ProductsModel values = snapshot.data;
   List<Product> results = values.data;
    List<List<Inventory>> productList=values.data[index].inventory;
    List<Inventory> productInventoryList=productList[0];       
                       productInventoryDropDown=productInventoryList[0]; // this variable must have 1 value of the list because in dart by default there is null value or provide the hintText to `DropdownButton` 
                         child: DropdownButton<Inventory>(
                          items: productInventoryList.map((proInventory) => 
                          DropdownMenuItem<Inventory>(
                            child: Text(proInventory.label+" "+proInventory.weight),
                            value: proInventory,
                          )).toList(),
                          onChanged: (Inventory value) {
                            setState(() {
                              productInventoryDropDown = value;
                            });
                          },
                          isExpanded: false,
                          value: productInventoryDropDown,
                          hint: productInventoryList[0].weight == null ? Text('Select Weight') : 
                              Text(productInventoryList[0].label+" "+productInventoryList[0].weight,
                            style: TextStyle(color: Colors.black),
                          ),
                        ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM