小编典典

颤振| 右对齐不起作用

flutter

尝试使容器与文本视图子级正确对齐,它的父级行位于另一列内,尝试了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个项目的文本

屏幕截图


阅读 230

收藏
2020-08-13

共1个答案

小编典典

使用小部件中的 mainAxisAlignment 属性 Row

new Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween, 
    ...
)
2020-08-13