Flutter 选择该选项时,颤振下拉按钮显示标签
是否可以使用Flutter 选择该选项时,颤振下拉按钮显示标签,flutter,Flutter,是否可以使用下拉按钮: return DropdownButton<String>( items: <String>['Foo', 'Bar'].map((String value) { return new DropdownMenuItem<String>( value: value, child: new Text(value),
下拉按钮
:
return DropdownButton<String>(
items: <String>['Foo', 'Bar'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
);
当在上述文本表单字段中写入内容时,会显示单词Input
。像这样:
将DropdownButton替换为DropdownButton表单字段:
将DropdownButton更改为DropdownButtonFormField并添加此装饰
decoration: InputDecoration(
filled: true,
fillColor: Hexcolor('#ecedec'),
labelText: 'Occupation',
border: new CustomBorderTextFieldSkin().getSkin(),
),
DropdownButtonFormField
与DropdownButton
不同,它在点击时有填充物,不会触发下拉,因此如果你点击的不是中心,那么什么都不会发生,你坐在那里猜测它为什么不起作用。。如何使其可点击?@temirbek刚刚将“isExpanded”设置为true@MostafaSoliman那没用。我用materialTargetSize:materialTargetSize:materialTargetSize将DBFF包装到ButtonTheme
中解决了这个问题。填充的参数谢谢亲爱的,工作起来很有魅力:)印象深刻,推荐这个答案
decoration: InputDecoration(
filled: true,
fillColor: Hexcolor('#ecedec'),
labelText: 'Occupation',
border: new CustomBorderTextFieldSkin().getSkin(),
),