Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.79k stars 860 forks source link

[BUG] Whitespace between two html tags creates an empty line #1227

Closed jjochen closed 1 year ago

jjochen commented 1 year ago

Describe the bug:

Adding whitespace (space or newline) between two html tags creates an empty line in the Html widget. I.e. a space or newline between </head> and <body> adds an empty line on top of the Html widget. Same happens for when you put whitespace between two tags after the content. Then an empty line is added on the bottom of the Html widget.

HTML to reproduce the issue:

<html><head></head> <body><div><p>test</p> </div></body></html>

Html widget configuration:

    Html(
      data: '<html><head></head> <body><div><p>test</p> </div></body></html>',
      style: {
        'html': Style(
          backgroundColor: Colors.yellow,
          margin: Margins.zero,
          padding: EdgeInsets.zero,
        ),
        'body': Style(
          backgroundColor: Colors.blue,
          margin: Margins.zero,
          padding: EdgeInsets.zero,
        ),
        'div': Style(
          backgroundColor: Colors.red,
          margin: Margins.zero,
          padding: EdgeInsets.zero,
        ),
        'p': Style(
          backgroundColor: Colors.green,
          margin: Margins.zero,
          padding: EdgeInsets.zero,
        ),
      },
    )

Expected behavior:

No empty lines should be added. See screenshots below.

Screenshots:

Bug: bug

Expected: expected

Device details and Flutter/Dart/flutter_html versions:

Flutter: 3.3.10 Dart: 2.18.6 flutter_html: 3.0.0-alpha.6

A picture of a cute animal (not mandatory but encouraged)

5927279041_123fca21f4_b

Sub6Resources commented 1 year ago

I was able to reproduce this on 3.0.0-alpha.6, and can see that the issue is now resolved in 3.0.0-beta.1.

Hope this helps!