简体   繁体   English

dropDownButton 选择时出现颤振错误

[英]Flutter Error while dropDownButton Select

Hi i am new in Flutter App developer,so please help.嗨,我是 Flutter App 开发人员的新手,所以请帮忙。 When first time app start then working fine but during select dorpdown value select then getting error using GridView.count当第一次应用程序启动然后工作正常但在选择 dorpdown 值时选择然后使用 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),
                          ),
                        ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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