如何解决Flutter下拉按钮溢出问题? [英] How to fix Flutter dropdown button overflow issue?
本文介绍了如何解决Flutter下拉按钮溢出问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个Flutter表单,然后创建一个带有flutter的下拉按钮.我正在将本地子数据丢失到下拉列表中.我的某些下拉菜单项很长.我使用SafeArea和ListView,并且在右边溢出.
I create a Flutter Form and I build a dropdown button with flutter. I am losing local son data into dropdown. Some of my items in dropdown button is long. I use SafeArea and ListView and I am getting overflow on right.
另一个问题未提及的部分解决方案,我在这里得到了答案.
partial solution not mentioned in the other question, and I get the answer here.
有什么想法要解决吗?
// TODO: BUILD RUN
return new Scaffold(
key: _scaffoldKey,
body: new SafeArea(
top: false,
bottom: false,
child: new Form(
key: _formKey,
child: new ListView(
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 32.0),
children: <Widget>[
//TODO: CURRENCY
new FormField<String>(
builder: (FormFieldState<String> state) {
return InputDecorator(
decoration: InputDecoration(
labelText: 'CHOOSE CURRENCY',
labelStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Colors.green.shade700),
errorText: state.hasError ? state.errorText : null,
),
isEmpty: _mySelectedCurrency == '',
child: new DropdownButtonHideUnderline(
child: new DropdownButton<String>(
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.w500,
),
value: _mySelectedCurrency,
isDense: true,
onChanged: (String newValue) {
setState(() {
_mySelectedCurrency = newValue;
state.didChange(newValue);
});
},
items: _itemsName,
),
),
);
},
validator: (val) {
return val != '' ? null : 'Choose Currency...';
},
),
],
))));
推荐答案
Though I have flagged the question as possible duplicate, a partial solution not mentioned in the other question is to use the isExpanded
property for DropDownButton
.
child: new DropdownButton<String>(
isExpanded: true,
...
这篇关于如何解决Flutter下拉按钮溢出问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文