I'm trying to leave the $
text in the top of the container, but even with FractionalOffset(1.0, 0.0)
the $
text continues in the middle of the container.
What could be done to leave the $
in the top of the container?
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'), ], ), ),
Flutter – Center Align Text in Text Widget To center align the text in a Text widget, provide textAlign property with value TextAlign. center .
In Flutter, to vertically center a child widget inside a Container, you can wrap the child widget with Column and add mainAxisAlignment: MainAxisAlignment. center to it.
right aligns the text left and right inside its boundaries respectively. TextAlign. justify horizontally justifies the text over its container. textDirection: textDirection is used to specify the direction of the text inside a Text Widget say ltr (left-to-right) or rtl (right to left).
Try giving your Row
a CrossAxisAlignment
of CrossAxisAlignment.start
. Is this what you had in mind?
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'), ], ), ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With