Home > Back-end >  Flutter text overflow in a Row
Flutter text overflow in a Row

Time:12-13

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?

CodePudding user response:

Wrap the second text in the Expanded widget

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