我的代码有问题,我定义了一个下拉按钮菜单,它会出现参数,当我单击参数时,它将选择该值,它不会在下拉按钮中改变。加上我的代码是在有状态小部件中定义的。这是我的代码:
String dropdownValue;
return DropdownButton<String>(
value: dropdownValue,
//icon: const Icon(Icons.arrow_downward,),
iconSize: 22,
elevation: 16,
style: TextStyle(color: Colors.black),
underline: Container(
height: 2,
color: Colors.black,
),
isDense: true,
hint: Padding(
padding: EdgeInsets.only(right: MediaQuery.of(context).size.width / 36),
child: Text('انتخاب موقعیت',
style: TextStyle(
fontFamily: "IranSans"
),
),
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>['One', 'Two', 'Three', 'Four', 'Five']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),