颤振| 右对齐不起作用
问题内容:
尝试使容器与文本视图子级正确对齐,它的父级行位于另一列内,尝试了Stack Overflow提供的多种解决方案,但均无效。
码
///Transactions Heading
new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Container(
alignment: Alignment.centerLeft,
margin: new EdgeInsets.only(top: 20.0, left: 10.0),
child: new Text(
"Transactions",
style: new TextStyle(
color: primaryTextColor,
fontSize: 25.0,
fontWeight: FontWeight.w700,
letterSpacing: 0.1,
),
),
),
new Container(
margin: new EdgeInsets.only(top: 25.0),
child: new Text(
currentGoalTransactions.length.toString() + " items",
style: new TextStyle(
color: darkHeadingsTextColor, fontSize: 15.0),
),
),
],
),
]);
想要在右边对齐2个项目的文本
问题答案:
使用小部件中的 mainAxisAlignment
属性 Row
。
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
...
)