0

I have a Row with two Text widgets in it:

Card(...
  Padding(...
    Column(...
      Padding(...
        Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text('Text'),
                Text('Long text'),
              ],
              ...

The output is something like this:

+----------------------------+
 Text               Long text 
+----------------------------+

If the second text is larger than the available space, I want something like this:

+----------------------------+
 Text Loooooooooooooooooooong 
      texttttttttttt 
+----------------------------+

but I get overflow error:

+----------------------------+
 Text Loooooooooooooooooooong texttttttttttt 
+----------------------------+

What should I do?

2 Answers 2

4

Wrap the second text in the Expanded widget

Row(
    children: [
      Text('Text'),
      Expanded(
        child: Text(
          'Loooooooooooooooooooong texttttttttttt ',
          textAlign: TextAlign.right,
        ),
      ),
    ],
),
Sign up to request clarification or add additional context in comments.

Comments

1

I would use flex to prevent it from taking the full size of the view

Row(
    children: [
      Text('Text'),
      Flexible(
        child: Text(
          'Loooooooooooooooooooong texttttttttttt ',
          textAlign: TextAlign.right,
        ),
      ),
    ],
),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.