[英]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.