Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLUTTER | Right Align not working

Tags:

Trying to right align a container with text view child, it has a row parent which is inside another column, tried number of solutions from Stack Overflow, didn't work.

Code

///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),                   ),                 ),               ],             ),        ]); 

Want to align the 2 items text to the right

Screenshot

like image 673
Musa Usman Avatar asked Jun 01 '18 09:06

Musa Usman


People also ask

Why text Align Center doesn't work?

Short answer: your text isn't centered because the elements are floated, and floated elements "shrink" to the content, even if it's a block level element.

How do you align in flutter?

Align Widget is the widget that is used to align its child within itself and optionally sizes itself based on the child's size. Align Widget is quite flexible and can change its size according to the size of its child. Properties of Align Widget: alignment: It sets the alignment.

How do you start align text 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 .


1 Answers

Use the mainAxisAlignment property in Row widget.

new Row(     mainAxisAlignment: MainAxisAlignment.spaceBetween,      ... ) 
like image 182
Vinoth Kumar Avatar answered Oct 14 '22 23:10

Vinoth Kumar