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,
),
Author by
Jithesh Kt
Senior software engineer. Expert in WordPress, CodeIgniter, PHP... almost all web 3.0 technologies.
Updated on December 07, 2022Comments
-
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:How to do this in Flutter?
It is a common layout and it is sad that it isn't documented anywhere :(
-
Jithesh Kt over 5 yearsThanks. But little bit confused, can you edit the answer and post a small snippet showing Text widget displaying two lines?
-
Jithesh Kt over 5 yearsThanks, blaneyneil, much appreciated :)
-
Delicia Fernandes over 3 yearsWrap the Text widget with Expanded if it doesn't work.