我目前正在使用Flutter web,我正在努力实现以下目标:
下拉菜单
我无法为下拉菜单设置标题,只能将标题作为项目添加到列表中。
我尝试了Firas Krifa的建议,得到了以下结果:
导致小幅面
产生4K大小的
正常网页大小(全高清(
我不知道为什么在小尺寸中,下拉菜单出现在下拉按钮的左侧,4k尺寸出现在右侧。同样在正常大小上,它出现在标题上,而我想要的是它正好落在标题下。
试试这个
new DropdownButton<String>(
items: <String>['A', 'B', 'C', 'D'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
)
小部件DropdownButtonHideUnderline
和Theme
将帮助控制下拉列表在AppBar
标题中的外观
https://material.io/guidelines/layout/structure.html#structure-应用程序栏
new AppBar(
title: new Theme(
child: new DropdownButtonHideUnderline(
child: new DropdownButton<String>(
value: _value,
items: <DropdownMenuItem<String>>[
new DropdownMenuItem(
child: new Text('My Page'),
value: 'one',
),
],
onChanged: (String value) {
setState(() => _value = value);
},
),
),
data: new ThemeData.dark(),
),
),