Flutter - 在Container中顶部对齐文本

时间:2017-06-13 15:00:49

标签: dart flutter

我试图将$文本留在容器的顶部,但即使使用FractionalOffset(1.0, 0.0)$文本也会继续放在容器的中间。

如何将$留在容器顶部?

  body: new Card(
    child: new Column(
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        new Container(
          padding: new EdgeInsets.only(top: 16.0),
          child: new Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              new Container(
                alignment: new FractionalOffset(1.0, 0.0),
                child: new Text(
                  '\$  ',
                  style: new TextStyle(
                    fontSize: 20.0,
                    fontFamily: 'Roboto',
                    color: new Color(0xFF26C6DA),
                  )
                )
              ),               
              new Text(
                '3,435.23',
                style: new TextStyle(
                  fontSize: 35.0,
                  fontFamily: 'Roboto',
                  color: new Color(0xFF26C6DA)
                ),
              )                 
            ],
          ),
        ),            
        new Text('general balance'),
      ],
    ),
  ),

enter image description here

2 个答案:

答案 0 :(得分:13)

尝试给Row CrossAxisAlignment CrossAxisAlignment.start body: new Card( child: new Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ new Container( padding: new EdgeInsets.only(top: 16.0), child: new Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new Text( '\$ ', style: new TextStyle( fontSize: 20.0, fontFamily: 'Roboto', color: new Color(0xFF26C6DA), ) ), new Text( '3,435.23', style: new TextStyle( fontSize: 35.0, fontFamily: 'Roboto', color: new Color(0xFF26C6DA) ), ) ], ), ), new Text('general balance'), ], ), ), 。这是你的想法吗?

screenshot

  JavaRDD<String> textFile = sc.textFile("C://test.txt");

答案 1 :(得分:0)

向右对齐

Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container()
],)