Skip to content

[flutter_markdown] Ordered number list uses SizedBox for bullet number, but doesn't scale text to fit properly #81749

@dannyvalentesonos

Description

@dannyvalentesonos

Internal: b/291644799

else if (tag == 'li') {
        if (_listIndents.isNotEmpty) {
          if (element.children.length == 0) {
            element.children.add(md.Text(''));
          }
          Widget bullet;
          dynamic el = element.children[0];
          if (el is md.Element && el.attributes['type'] == 'checkbox') {
            bool val = el.attributes['checked'] != 'false';
            bullet = _buildCheckbox(val);
          } else {
            bullet = _buildBullet(_listIndents.last);
          }
          // See flutter/flutter_markdown#147 and flutter/flutter_markdown#169
          child = Row(
            textBaseline: TextBaseline.alphabetic,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              SizedBox(
                width: styleSheet.listIndent,
                child: bullet
              ),
              Expanded(child: child)
            ],
          );
        }
      }

This creates a SizedBox with the listIndent for the width of the box, however if the font causes one of the numbers to be slightly larger than the allotted size, the period overflows to the next line.

If the numbered list ends up causing double digits, this can also cause an issue.

Finally, if the font is scaled on the system, this will end up looking very bad too.

Using a FittedBox around the bullet widget would fix this so that at least the numbers and periods stay on one line and always fit in the given size, though it could look weird to have a much smaller number compared to the rest, when that happens. But I think it would still be better than the current behavior.

This is without the FittedBox
Simulator Screen Shot - iPhone 8 - 2020-08-10 at 19 52 24

This is with the FittedBox
Simulator Screen Shot - iPhone 8 - 2020-08-10 at 19 52 14

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectcustomer: googleVarious Google teamsp: flutter_markdownflutter/packages flutter_markdownpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy