我最近开始使用dart 和Flutter 翼编程,我的应用程序一切都很顺利,尽管最近我想增加下拉菜单,为用户提供多种 Select .但是,当我从列表中 Select 一个值时,它不会改变框中的值,它会返回到提示或空框.如有任何帮助,我们将不胜感激!
下面是我的下拉按钮代码:
Widget buildDropdownButton() {
String newValue;
return new Padding(
padding: const EdgeInsets.all(24.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new ListTile(
title: const Text('Frosting'),
trailing: new DropdownButton<String>(
hint: Text('Choose'),
onChanged: (String changedValue) {
newValue=changedValue;
setState(() {
newValue;
print(newValue);
});
},
value: newValue,
items: <String>['None', 'Chocolate', 'Vanilla', 'ButterCream']
.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList()),
),
],
),
);
}