【发布时间】:2021-06-26 13:28:17
【问题描述】:
我有一个列,它的所有子项都是单词行(文本小部件),每行都有 MainAxisAlignment.spaceBetween 的主要对齐方式。我想将列的宽度设置为子项之间最长的行,并且其他行将相应地更改它们之间的空间。
我的代码:
Container(
color: Colors.green,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('A', style: Theme.of(context).textTheme.headline4),
Text('B', style: Theme.of(context).textTheme.headline4),
Text('C', style: Theme.of(context).textTheme.headline4)
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('A', style: Theme.of(context).textTheme.headline4),
Text('B', style: Theme.of(context).textTheme.headline4),
Text('C', style: Theme.of(context).textTheme.headline4),
Text('D', style: Theme.of(context).textTheme.headline4),
Text('E', style: Theme.of(context).textTheme.headline4),
]),
]))
假设我不能在容器中将列宽设置为固定宽度,我该如何(动态地)将其设置为最长行?
【问题讨论】: