Search code examples
flutterrow

Add multiple line in Row Widget


I have wrapped 3 Text in Row, but get exceptions. How can I make them displayed multiple line ?

 Row(children: [
     Text("this is text 1 bla bla bla"),
     Text("this is text 2 bla bla bla"),
     Text("this is text 3 bla bla bla"),
    ],),

Error

════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by 26 pixels on the right.
The relevant error-causing widget was
Row

Solution

  • You can use Flexible to solve this

          Row(children: [
            Flexible(child: Text("this is text 1 bla bla bla")),
            Flexible(child: Text("this is text 2 bla bla bla")),
            Flexible(child: Text("this is text 3 bla bla bla")),
          ])
    

    Or you can use Wrap to show as a grid

          Wrap(children: [
            Text("this is text 1 bla bla bla"),
            Text("this is text 2 bla bla bla"),
            Text("this is text 3 bla bla bla"),
          ])