简体   繁体   English

Flutter 下拉按钮选择的值没有改变

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM