Skip to content

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

Description

@gazreese

Migrated from flutter/flutter#81749
This issue was originally filed against the official flutter_markdown package.
The package has since been discontinued and ownership transferred to flutter_markdown_plus.


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

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions