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

Viewed 1891

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

2 Answers

Try this

new Container(
       child: Row(
         children: <Widget>[
            Flexible(
               child: new Text("sample text"))
                ],
        ));
Row(
         children: <Widget>[
            Expanded(
               child: new Text("your text"))
                ],
        )
Related