我正在尝试将两个极端对齐,一个在左侧,一个在右侧。 我有一行左对齐,然后该行的一个子行右对齐。但是,似乎子行正在从其父行获取对齐属性。这是我的代码
var SettingsRow = new Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text("Right",softWrap: true,),
],
);
var nameRow = new Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text("Left"),
SettingsRow,
],
);
结果我得到了这样的东西
Left Right
我想要的是
Left Right
Row 上也有足够的空间。我的问题是为什么子行没有展示其 MainAxisAlignment.end
属性?
最佳答案
使用单个 Row
代替 mainAxisAlignment: MainAxisAlignment.spaceBetween
。
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text("left"),
new Text("right")
]
);
或者你可以使用扩展
new Row(
children: [
new Text("left"),
new Expanded(
child: settingsRow,
),
],
);
https://stackoverflow.com/questions/50365770/