Skip to content

Feature request: Make 4 pixel indentation and text alignment for ordered numbers lists customizable #115

@gazreese

Description

@gazreese

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


It would really be helpful if the 4 pixel indentation in this method was customizable.

Widget _buildBullet(String listTag) {
    if (listTag == 'ul') {
      return Text(
        '•',
        textAlign: TextAlign.center,
        style: styleSheet.listBullet,
      );
    }

    final int index = _blocks.last.nextListIndex;
    return Padding(
      padding: const EdgeInsets.only(right: 4),    <======= Customize this please!
      child: Text(
        '${index + 1}.',
        textAlign: TextAlign.right,
        style: styleSheet.listBullet,
      ),
    );
  }

and if the cross axis alignment of the Row widget when building the bullet row in here was customizable too:

} 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.baseline,    <======= Customize this please!
            children: <Widget>[
              SizedBox(
                width: styleSheet.listIndent,
                child: bullet,
              ),
              Expanded(child: child)
            ],
          );
        }
      }

Just like the listIndent property of the Stylesheet, it would be great having 2 other properties to customize the indentation between the bullet number and the text, and the alignment between the bullet number and the text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions