【发布时间】:2020-02-13 10:38:58
【问题描述】:
根据标题,我想在TextFormField 中添加一个DropdownButton 作为prefix(或prefixIcon?)。文本字段是金额,下拉菜单是货币。
我的直接方法在视觉上有效,但我无法点击下拉菜单来显示列表。每次我点击它时,它都会显示(并立即隐藏)文本字段本身的键盘。
怎么做?
TextFormField(
initialValue: '10.00',
decoration: InputDecoration(
prefix: DropdownButtonHideUnderline(
child: DropdownButton(
items: CURRENCY_CODES,
onChanged: _onCurrencyChanged,
value: _currency,
),
),
),
),
【问题讨论】:
-
你能用你正在采取的方法发布代码吗?
-
您是否尝试过使用两个单独的小部件将它们与
Row包装起来?我不认为prefix可以与DropdownButton一起使用。根据文档,prefix can be used, for example, to add some padding to text that would otherwise be specified using prefixText, or to add a custom widget in front of the input. -
@PabloBarrera 问题已更新。
-
@Marat 我将文本字段自定义为带有阴影的圆角,所以我更喜欢将所有内容都放在里面。
标签: flutter