Skip to content

Improve the ListTile docs: explain the Text maxLines dependency #15423

Closed

Description

@kylegoetz

Flutter beta.

Docs say ListTiles are all the same height, and all 1–3 lines high. When I build ListTiles with subtitle property containing a very length Text object, those ListTiles are wayyyy taller than three lines and certainly not of equal height like the docs say they're supposed to (even if you construe "three lines" as "three spans of text separated by \n".

See screenshot. These are two ListTiles.

screen shot 2018-03-11 at 23 07 49

Relevant code:

    new ListView(
        shrinkWrap: true,
        scrollDirection: Axis.vertical,
        ListTile.divideTiles(
            color: Colors.deepOrange,
            tiles: items.map((item) {
                return _buildRow(item);
            }).toList()
        ).toList()
    )

    Widget _buildRow(Item item) {
        return new Dismissible(
            key: new Key(item.id.toString()),
            //...
            child: new Padding(
                child: new ListTile(
                    title: new Text(item.title),
                    subtitle: new Text(item.content),
                    textAlign: TextAlign.justify
                )
                //...
            )
        );
    }

Activity

  1. Hixie commented on Mar 12, 2018

    @Hixie
    Contributor

    cc @gspencergoog

    We probably lost some limits when adding support for text scaling; I guess the texts should have explicit maxLines and ellipses enabled.

  2. kylegoetz commented on Mar 12, 2018

    @kylegoetz
    Author

    I just implemented some truncation just to keep really long content from making a full-screen ListTile and I can see the ListTiles are not the same height (any of them; they're all slightly different). Is it because the ListTiles are wrapped in a Dismissible, so that maybe ListView no longer can set the height of the ListTiles to be the same? Do the ListTiles have to be immediate children of ListView?

  3. kylegoetz commented on Mar 12, 2018

    @kylegoetz
    Author

    screen shot 2018-03-11 at 23 30 18

  4. gspencergoog commented on Mar 12, 2018

    @gspencergoog
    Contributor

    Yeah, the ListTile only knows that the title and subtitle are widgets. The parameter "isThreeLine" is a little misleading in that regard, and we should probably document that better. Three line tiles differ from two line tiles only in their min height. One line tiles have a smaller min height than two line, and also don't show the subtitle widget.

    It does expand to fit the widgets put inside it, so you will need to set maxLines and overflow on your Text arguments to match what you want your limits to be.

    Or perhaps those should be added to a DefaultTextStyle inside of the ListTile...

  5. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    a: qualityA truly polished experience
    on Jun 8, 2018
  6. added this to the milestone on Jun 8, 2018
  7. HansMuller commented on Jun 12, 2018

    @HansMuller
    Contributor

    The documentation for ListTile.title, ListTile.subtitle, ListTile.isThreeLine should explain the need for setting maxLines in Text widgets.

  8. changed the title [-]ListTile WAY longer than three lines![/-] [+]Improve the ListTile documentation: explain the Text maxLines dependency[/+] on Jun 12, 2018
  9. changed the title [-]Improve the ListTile documentation: explain the Text maxLines dependency[/-] [+]Improve the ListTile docs: explain the Text maxLines dependency[/+] on Jun 12, 2018
  10. Hixie commented on Jun 18, 2018

    @Hixie
    Contributor

    Could ListTile set the maxLines using DefaultTextStyle?

  11. marchenko1985 commented on Jan 13, 2019

    @marchenko1985

    Not sure if it is related or not, but there is no docs explaining how ListTile works with contentPadding, margin and probably something like min height.

    I'am trying to build column with 2 divided list tiles, one of them has long text.

    There is no extension point to make "paddings" between dividers to be the same for both single line and multi line list tiles.

  12. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  13. self-assigned this
    on Jul 2, 2020
  14. modified the milestones: , 1.21 - July 2020 on Jul 2, 2020
  15. github-actions commented on Aug 19, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: qualityA truly polished experienced: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packageswaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions