Flutter Dropdownbutton 选择的值没有改变
Flutter Dropdownbutton selected value is not changing
Flutter Dropdownbutton 选择的值没有改变我正在使用 dropdownbutton 并使用 Product 模型映射数据但是 onchange 我的值没有改变
DropdownButtonHideUnderline(
child: DropdownButton<Product>(
hint: Text("Select Product"),
dropdownColor: Colors.white,
isExpanded: true,
items: _productController.products
.map((Product value) {
return new DropdownMenuItem<Product>(
value: value,
child: new Text(value.productName),
);
}).toList(),
onChanged: (Product val) {
_stockController.price.text = val.price;
_stockController.productName.text = val.productName;
selectedProduct = val.productName;
TextStyle(color: Colors.black);
setState(() {});
},
),
),
您没有指定此小部件的 value
属性。我认为它应该设置为 selectedProduct
的值。
什么是单独的 TextStyle
?它用作 style
属性 小部件的值,不能单独使用。
Flutter Dropdownbutton 选择的值没有改变我正在使用 dropdownbutton 并使用 Product 模型映射数据但是 onchange 我的值没有改变
DropdownButtonHideUnderline(
child: DropdownButton<Product>(
hint: Text("Select Product"),
dropdownColor: Colors.white,
isExpanded: true,
items: _productController.products
.map((Product value) {
return new DropdownMenuItem<Product>(
value: value,
child: new Text(value.productName),
);
}).toList(),
onChanged: (Product val) {
_stockController.price.text = val.price;
_stockController.productName.text = val.productName;
selectedProduct = val.productName;
TextStyle(color: Colors.black);
setState(() {});
},
),
),
您没有指定此小部件的 value
属性。我认为它应该设置为 selectedProduct
的值。
什么是单独的 TextStyle
?它用作 style
属性 小部件的值,不能单独使用。