Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Always display text on two lines

I have Text:

Text(
  "My long ... long ... text",
  style: const TextStyle(overflow: TextOverflow.ellipsis),
  maxLines: 2,
),

In case text is long, it will be displayed on two lines only. My question is: is it possible to, in case of short text, to take the same space as this long text (as two lines)? I need to calculate the height and therefore I need to take into account two lines everytime. Also in case there is only short text. Thank you for your advise.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Add \n to create a new line at the end.

 Text(
   '${myString}\n'
 ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading