简体   繁体   中英

flutter listTile with a long text for the Title

I have a listTile title with a long text.

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

like: exampl....

if I don´t use softWrap: true, overflow: TextOverflow.ellipsis, the text is shown in 3 or 4 lines

I tryied using FittedBox, but the text get´s really small.. unreadable....

Any ideias how to get this?

title: Text( inc.descricao, style: TextStyle( color: 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. My guess is Text widget container making the Text widget shorter

Try wrapping Text widget in Container with maximum width

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

You can use text property 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,
              ),
            )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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