1

So, I want the row with a string of 2 lines ("Some long string with 2 lines heres") to be properly aligned with the string of 1 line: ("Name:"), but I want to do this WITHOUT checking the string length.

This is my code for the row:

Row( children: <Widget>[ Text( title, style: Theme.of(context).textTheme.headline6.copyWith(height: 1.24), ), Spacer(), Container( width: 242.0, alignment: Alignment.bottomRight, child: Text( text, textAlign: TextAlign.end, maxLines: 2, style: Theme.of(context).textTheme.bodyText1.apply( color: kGrey, ), ), ), ], ); 

As for the result I want, here's an image example:

enter image description here

1
  • Can you explain better Commented Jun 22, 2020 at 14:07

1 Answer 1

2

Use crossAxisAlignment Row parameter to align the text to start crossAxisAlignment: CrossAxisAlignment.start

Solution-

 Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( title, style: Theme.of(context) .textTheme .headline6 .copyWith(height: 1.24), ), Spacer(), Container( width: 242.0, alignment: Alignment.bottomRight, child: Text( text, textAlign: TextAlign.end, maxLines: 2, style: Theme.of(context).textTheme.bodyText1.apply( color: kGrey, ), ), ), ], ), 

Hope this will help you If you have any doubts ask in comment.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, it was that simple. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.