Show paragraph with ellipsis in Flutter

6,724

use overflow in addition to maxlines. if you need to adhere to a really tight fixed height then you can easily calculate what maxlines should be based upon your font size.

Text(
  'my super long string',
  textAlign: TextAlign.left,
  overflow: TextOverflow.ellipsis,
  maxLines: 3,
),
Share:
6,724
Jithesh Kt
Author by

Jithesh Kt

Senior software engineer. Expert in WordPress, CodeIgniter, PHP... almost all web 3.0 technologies.

Updated on December 07, 2022

Comments

  • Jithesh Kt
    Jithesh Kt about 1 month

    I know how to use ellipsis with the Text widget. overflow: TextOverflow.ellipsis does the job very well. But my problem is it actually displays only one line. I am trying to make a layout something similar to the below image:

    Expected design

    How to do this in Flutter?

    It is a common layout and it is sad that it isn't documented anywhere :(

  • Jithesh Kt
    Jithesh Kt about 4 years
    Thanks. But little bit confused, can you edit the answer and post a small snippet showing Text widget displaying two lines?
  • Jithesh Kt
    Jithesh Kt about 4 years
    Thanks, blaneyneil, much appreciated :)
  • Delicia Fernandes
    Delicia Fernandes about 2 years
    Wrap the Text widget with Expanded if it doesn't work.