flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] list marker alignment broken when setting lineHeight

Open quaaantumdev opened this issue 3 years ago • 3 comments

Describe the bug: Setting lineHeight on "li" element breaks alignment of list marker for both "ol" and "ul".

HTML to reproduce the issue:

<ol>
  <li>The dot displayed at the list item</li>
  <li>will be displayed above the middle line</li>
  <li>when setting styles "li" to lineHeight: LineHeight.em(1.3)</li>
</ol>

<ul>
  <li>The number displayed at the list item</li>
  <li>will be displayed above the middle line</li>
  <li>when setting styles "li" to lineHeight: LineHeight.em(1.3)</li>
</ul>

Html widget configuration:

final styles = <String, Style>{
  'body': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'ul': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'ol': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'li': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
}

Expected behavior: List item markers should be aligned with the text inside the list item.

Screenshots: image

Device details and Flutter/Dart/flutter_html versions: flutter_html: 2.2.1 (latest at the moment) flutter: 2.10.1 (stable) dart: 2.16.1 (comes with flutter)

Additional info: Checked the source code, looks like a Row layout with a Text element is created, maybe consider using the textStyle from the list item or allow a custom text style. There is a workarround for "ul" by using "listStyleType: ListStyleType.fromWidget(...)" with some margin on top, but it does not work for "ol" as one cannot provide the numbers dynamically.

A picture of a cute animal (not mandatory but encouraged) A list of perfectly aligned cats 😺 A list of perfectly aligned cats

quaaantumdev avatar Feb 26 '22 00:02 quaaantumdev

I have same issue to !!

untillnesss avatar Mar 10 '22 04:03 untillnesss

image

untillnesss avatar Mar 10 '22 10:03 untillnesss

I'm facing same problem. Any update on this?

daniel-tan1 avatar Jul 01 '22 03:07 daniel-tan1