簡體   English   中英

dropDownButton 選擇時出現顫振錯誤

[英]Flutter Error while dropDownButton Select

嗨,我是 Flutter App 開發人員的新手,所以請幫忙。 當第一次應用程序啟動然后工作正常但在選擇 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