Search code examples
flutterdartflutter-layout

Is it possible to force Text widget to use two line space?


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.

enter image description here

Does anyone know some trick to force Text widget to use maxLines space even if only one line is needed?


Solution

  • 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,
    )