如何在颤动中更改 DropdownButton 的高度。我曾尝试使用 Padding 和 SizedBox,但没有一个真正起作用。
SizedBox 只是增加了容器大小,而 DropdownButton 被夹在左上角,因此不再居中。填充被忽略或将内容移到按钮之外。
我不想更改下拉覆盖的大小,而是更改按钮本身。
build(BuildContext context) {
return ThemeData(
data: ThemeData(canvasColor: Colors.white),
child: DropdownButton(
items: _items.map((item) => DropdownMenuItem(child: Text(item), value: item)).toList(),
isExpanded: true,
selectedItemBuilder: (_) {
return _items.map<Widget>((String lang) {
return Center(
widthFactor: 1,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(lang, style: TextStyle(color: Colors.black))
),
);
}).toList();
}
)
)
}