Flutter Multiline for text

问题描述 投票:3回答:3

我需要的只是我的文字是多行的。我给了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,
            ),
          )
        ],
      ),
    )
android flutter flutter-layout
3个回答
4
投票

我想你忘了添加overflow类型。

你可以使用这样的东西:

Text(
     "TOP ADDED",
     textAlign: TextAlign.justify,
     overflow: TextOverflow.ellipsis,
     style: TextStyle(fontSize: 18.0),
     maxLines: 2,)

4
投票

确保父窗口小部件限制文本的宽度,然后使用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,
  ),
),

0
投票

也许尝试使用TextField

new TextField(
  keyboardType: TextInputType.multiline,
  maxLines: 2,
)
© www.soinside.com 2019 - 2024. All rights reserved.