Skip to content

Conversation

@kylesean
Copy link

@kylesean kylesean commented Jan 7, 2026

Summary

This PR fixes two related issues with ordered list rendering:

  1. Numbers not vertically aligned - Numbers now use a dynamically calculated fixed width
  2. Style override issue (Ordered list number's font overrides font settings #105) - Numbers now respect user-configured text styles
    Fixes Ordered list number's font overrides font settings #105

Changes

  • OrderedListView: Added dynamic width calculation using TextPainter
  • OrderedListView: Added optional numberWidth parameter for manual override
  • OrderedListView: Improved RTL support (left-align numbers in RTL mode)
  • OrderedList: Removed forced fontWeight: FontWeight.w100 override

Testing

  • flutter analyze passes
  • flutter test passes

Fixes Infinitix-LLC#105

## Problems Fixed

1. **Alignment Issue**: Ordered list numbers (1., 2., 10., etc.) were not
   vertically aligned because numbers had variable width based on digit count.

2. **Style Override Issue (Infinitix-LLC#105)**: Ordered list numbers were forcing
   fontWeight: FontWeight.w100, overriding user-configured text styles.

## Solution

### For Alignment:
- Calculate width dynamically using TextPainter based on '99.' width
- This adapts to different font sizes automatically
- Apply right-alignment (TextAlign.right) for LTR text
- Apply left-alignment (TextAlign.left) for RTL text

### For Style Override:
- Remove the forced fontWeight override in OrderedList component
- Pass through config.style directly to OrderedListView

## Changes

1. `unordered_ordered_list.dart`:
   - Add optional `numberWidth` parameter to `OrderedListView`
   - Calculate width dynamically using current font style if not specified
   - Use '99.' as reference to accommodate lists up to 99 items
   - Wrap number Text in SizedBox with proper text alignment

2. `markdown_component.dart`:
   - Remove forced `fontWeight: FontWeight.w100` override
   - Pass `config.style` directly to OrderedListView

## Testing
- flutter analyze passes
- flutter test passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ordered list number's font overrides font settings

1 participant