Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to auto expand when text is too long in Row in flutter

Tags:

flutter

Now I am using this code to show text in flutter, this is my code:

Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Padding(
                    padding: const EdgeInsets.only(top: 8, bottom: 8.0),
                    child: Text(
                      item.subName,
                      softWrap: true,
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                  ),
                ],
              ),

sometimes the text item.subName is too long, how to make it auto expand or render in new line when the text overflow? I have tried to add this but still not work:

 softWrap: true,

This is the error:

enter image description here

like image 458
Dolphin Avatar asked Nov 02 '25 13:11

Dolphin


2 Answers

Try this

new Container(
       child: Row(
         children: <Widget>[
            Flexible(
               child: new Text("sample text"))
                ],
        ));
like image 57
Ashok Avatar answered Nov 04 '25 03:11

Ashok


Row(
         children: <Widget>[
            Expanded(
               child: new Text("your text"))
                ],
        )
like image 39
Sanket Avatar answered Nov 04 '25 03:11

Sanket