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 over 1 year

    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 over 5 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 over 5 years
    Thanks, blaneyneil, much appreciated :)
  • Delicia Fernandes
    Delicia Fernandes over 3 years
    Wrap the Text widget with Expanded if it doesn't work.