I need to find out a method to force Flutter Text widget to use two text lines space even if the line is only one.
For example in the below photo one card is lower than the other one due to the fact that Text widget use only one line space.

Does anyone know some trick to force Text widget to use maxLines space even if only one line is needed?
Adding minLines to Text is currently an open feature request. You can track it here
For now, a suggested workaround is to use:
str = 'example';
Text(
str + '\n',
maxLines: 2,
)
you can use \n to set minimum lines (it is a trick)
this issue is still open Github: Add minLines to Text (flutter issue)
Text(
'${product.name}\n\n', //equal minlines: 3
maxLines: 3,
overflow: TextOverflow.ellipsis,
style:
const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With