[英]Flutter Dropdownbutton selected value is not changing
Flutter Dropdownbutton selected value is not changing I am using dropdownbutton and mapping data using Product model but onchange my value is not changing Flutter 下拉按钮选择的值没有改变我正在使用下拉按钮和映射数据使用产品 model 但 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(() {});
},
),
),
You didn't specify the value
property of this widget.您没有指定此小部件的value
属性。 I think it should be set to value of selectedProduct
.我认为它应该设置为selectedProduct
的值。 And what the separate TextStyle
?什么是单独的TextStyle
? It is used as value for style
property of widgets and cannot be used as standalone.它用作小部件style
属性的值,不能单独使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.