如何在 Flutter 中为 DropDownButton 提供恒定宽度?
当我知道为什么它们在下图中都作为不同宽度大小的 DropDownButton 时,第一个是其中值“100%”的最高长度,第二个是其中的最高值“90%”,所以有字符串长度的差异,因此它相应地换行。
我想给他们一个固定的宽度,让他们看起来一样。
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(title,
style: Theme.textTheme.body1
.copyWith(fontWeight: ThemeData.medium)),
DropdownButton(
disabledHint: Text(defaultValue),
value: currentDropDownItem,
items: dropDownItemList,
onChanged: isEnabled
? (value) {
if (onValueChanged != null) {
onValueChanged(value);
}
}
: null,
),
])