Flutter Dropdownbutton selected value is not changing I am using dropdownbutton and mapping data using Product model but onchange my value is not changing
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. I think it should be set to value of selectedProduct
. And what the separate TextStyle
? It is used as value for style
property of widgets and cannot be used as standalone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.