Column(children: [
Row(children: [
SizedBox(width: 200,
child: Text('Name')),
Flexible(
child: Text('John')),
),
],
Row(children: [
SizedBox(width: 200,
child: Text('Order Id')),
Flexible(
child: MenuItemButton(
child: Text('123456')),
),
],
]);
MenuItemButton 展开以占据行中的所有可用空间。它具有左填充/边距,因此不会与同一列中的其他值对齐。
Name | John
-----------------------------
Order Id | 123456 |
如何让 MenuItemButton 具有适合其子项的宽度?如何删除其左侧填充以与“John”对齐?
尝试过:
MenuItemButton(
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: MaterialStatePropertyAll(Size(0, 0))),
child: Text('123456'))
左侧填充来自 TextButtonStyle 的默认填充,可以使用
style
进行操作
MenuItemButton(
style: ButtonStyle(
padding: MaterialStatePropertyAll(
EdgeInsets.all(0),
),
),
child: Text('123456'),