Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Top align text in Container

Tags:

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'),       ],     ),   ), 

enter image description here

like image 791
rafaelcb21 Avatar asked Jun 13 '17 15:06

rafaelcb21


People also ask

How do you align text within a container in Flutter?

Flutter – Center Align Text in Text Widget To center align the text in a Text widget, provide textAlign property with value TextAlign. center .

How do you align text vertically in container Flutter?

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.

How do you align text right in Flutter?

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).


1 Answers

Try giving your Row a CrossAxisAlignment of CrossAxisAlignment.start. Is this what you had in mind?

screenshot

 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'),       ],     ),   ), 
like image 105
Collin Jackson Avatar answered Sep 18 '22 22:09

Collin Jackson