简体   繁体   English

flutter listTile,标题为长文本

[英]flutter listTile with a long text for the Title

I have a listTile title with a long text.我有一个带有长文本的 listTile 标题。

I whoud like the title to show as must text as possible, in one single line...我希望标题尽可能多地显示文字,在一行中......

If I use softWrap: true, overflow: TextOverflow.ellipsis, the text is cut after 4 caracter´s如果我使用softWrap:true,溢出:TextOverflow.ellipsis,则文本在4个字符后被剪切

like: exampl....比如:例如……

if I don´t use softWrap: true, overflow: TextOverflow.ellipsis, the text is shown in 3 or 4 lines如果我不使用 softWrap:true,溢出:TextOverflow.ellipsis,文本显示为 3 或 4 行

I tryied using FittedBox, but the text get´s really small.. unreadable....我尝试使用 FittedBox,但文字真的很小.. 无法阅读....

Any ideias how to get this?任何想法如何得到这个?

title: Text( inc.descricao, style: TextStyle( color: Colors.white, fontFamily: "Roboto", fontSize: 16, ),标题:文本(inc.descricao,样式:TextStyle(颜色:Colors.white,fontFamily:“Roboto”,fontSize:16,),

   softWrap: true,
    overflow: TextOverflow.ellipsis,
  ),

thank You Roque谢谢你罗克

Use layout Flexible/Container with text overflow:使用带有文本溢出的布局灵活/容器:

Flexible(
  child: Container(
    child: Text(
      'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
      overflow: TextOverflow.ellipsis,
      style: TextStyle(
        fontSize: 13.0,),
    ),
  ),
),

Actually, overflow: TextOverflow.ellipsis should work.实际上, overflow: TextOverflow.ellipsis应该可以工作。 My guess is Text widget container making the Text widget shorter我的猜测是 Text 小部件容器使 Text 小部件更短

Try wrapping Text widget in Container with maximum width尝试将 Text 小部件包装在具有最大宽度的容器中

      Container(
        width: double.infinity,
        child: Text(
          'reaaaaaly long text, like reaaaaaaaaaaaaaly long',
          overflow: TextOverflow.ellipsis,
        ),

You can use text property Overflow.elipsis.您可以使用文本属性Overflow.elipsis。

              ListTile(
              shape: RoundedRectangleBorder(
                
              minLeadingWidth: 0,
                                title: Text(
                "Hello Overflow",
             
             
                style: const TextStyle(
                  fontFamily: 'Open Sans',
                  fontSize: 15,
                  color: Color(0xff23233c),
                  letterSpacing: -0.44999999999999996,
                  fontWeight: FontWeight.w500,
                ),
                softWrap: true,
                overflow: TextOverflow.ellipsis,
              ),
            )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM