我需要的只是我的文字是多行的。我给了maxLines
的财产,但它仍然得到RenderFlex
溢出错误到右边,因为下一个不会到第二行,
Align( alignment: Alignment.bottomCenter,
child: new ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: new Text(
"This is a very bigggggggg text !!!",textDirection: TextDirection.ltr,
style: new TextStyle(fontSize: 20.0, color: Colors.white),
maxLines: 2,
),
)
],
),
)
我想你忘了添加overflow
类型。
你可以使用这样的东西:
Text(
"TOP ADDED",
textAlign: TextAlign.justify,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18.0),
maxLines: 2,)
确保父窗口小部件限制文本的宽度,然后使用overflow和maxlines,例如:
Container(
width: 150,
child: Text(
"This text is very very very very very very very very very very very very very very very very very very very very very very very very very long",
overflow: TextOverflow.ellipsis,
maxLines: 5,
),
),
也许尝试使用TextField
:
new TextField(
keyboardType: TextInputType.multiline,
maxLines: 2,
)