skip to Main Content

On the documentation for ListTile, it notes:

"It is the responsibility of the caller to ensure that title does not wrap, and to ensure that subtitle doesn’t wrap (if isThreeLine is false) or wraps to two lines (if it is true)."

…without further explanation. The documentation for the title property also mirrors this recommendation:

"This should not wrap. To enforce the single line limit, use Text.maxLines."

Is this merely a recommendation for aesthetic purposes or are there performance or behavioral considerations?

I ask because I have list items that I want the texts to actually wrap and don’t know if I should be using a different widget instead.

I did not find any explanation on this after searching the docs and googling around.

2

Answers


  1. Definitely, it has no impact on performance. It is just a recommendation and indication of how the widget works.

    Remember that Flutter gives you the ability to customize and use widgets as you prefer. If you want to use a container and a row for this purpose, feel free to do so, but there is no silver bullet for these cases.

    On the other hand, there are widgets that come with specific features designed to facilitate accessibility on devices, and we should take this into consideration.

    Login or Signup to reply.
  2. The best way to find out is to try it – if your text for either the title or subtitle is longer than one line, it will just wrap within the list tile.

    However, this may contravene the material spec the ListTile widget is following depending on where it is wrapping, and this is what the documentation is letting you know – the ListTile widget does nothing to constrain its children to a certain number or rows, and that is instead your responsibility.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search