[英]how to make drop down menu Flutter
There's a Widget
called DropDownButton
.有一个名为DropDownButton
的Widget
。 For more information check out the docs for that Widget.有关更多信息,请查看该小部件的文档。 You can add items to the menu by passing a List<DropdownMenuItem<T>>
to it's items
parameter.您可以通过将List<DropdownMenuItem<T>>
传递给它的items
参数来将项目添加到菜单中。
DropdownButton<String>(
value: dropdownValue,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>['One', 'Two', 'Free', 'Four']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.