Android 颤振下拉校准不正确
我想要像这样的下拉菜单和颤振 预期: 有了Flatter dropdownformfield,我可以做如下事情 如您所见,当我单击下拉按钮时,菜单项与按钮重叠。请在下面查找代码Android 颤振下拉校准不正确,android,flutter,dart,mobile-development,Android,Flutter,Dart,Mobile Development,我想要像这样的下拉菜单和颤振 预期: 有了Flatter dropdownformfield,我可以做如下事情 如您所见,当我单击下拉按钮时,菜单项与按钮重叠。请在下面查找代码 DropdownButtonFormField( isExpanded: false, isDense: true, items: classes.
DropdownButtonFormField(
isExpanded: false,
isDense: true,
items: classes.map((category) {
return new DropdownMenuItem(
value: category,
child: Row(
children: <Widget>[
Text(category),
],
));
}).toList()
,
onChanged: (newValue) {
// do other stuff
},
value: _classroom,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(10, 0, 10, 0),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
hintText: "Select Class",
hintStyle: TextStyle(
color: Colors.grey[600],
),
),
)
DropdownButtonFormField(
isExpanded:错,
是的,
项目:classes.map((类别){
返回新的DropdownMenuItem(
值:类别,
孩子:排(
儿童:[
文本(类别),
],
));
})托利斯先生()
,
一旦更改:(newValue){
//做其他事情
},
价值观:_教室,
装饰:输入装饰(
contentPadding:EdgeInsets.fromLTRB(10,0,10,0),
enabledBorder:UnderlineInputBorder(
borderSide:borderSide(颜色:Colors.white)),
hintText:“选择类”,
hintStyle:TextStyle(
颜色:颜色。灰色[600],
),
),
)
使用下拉小部件可以实现这一点吗?如果没有,我如何设计自定义下拉小部件
谢谢默认情况下,颤振会在菜单按钮下方显示下拉菜单。在这种情况下,它重叠的原因是因为菜单中的项目太多,无法将它们全部显示在屏幕上,从而将菜单向上推,以便能够显示更多项目。你想如何改变这种行为取决于你自己。如果您想自定义自己的下拉菜单,该菜单的代码是开源的,您可以通过右键单击代码中的
dropdownbutonformfield
类并选择“转到源代码”(或IDE中的任何等效项)来查看它。将它复制到一个新类中,并随意编辑。即使我只有一个菜单项,它也是重叠的。