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] #1150

Open YoofiBP opened 1 year ago

YoofiBP commented 1 year ago

Describe the bug: I am rendering a table but cannot seem to obtain full widths when using both percentages and pixels. I even tried wrapping the HTML widget in a full width container.

Below is what it looks like

Screenshot 2022-09-28 at 7 55 05 PM

HTML to reproduce the issue:

<table width="2000px">
 <tr>
  <td colspan="2" style="border:2px solid black">Some other text</td>
  <td style="border:2px solid black">Some text</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
</table>

Html widget configuration:

Html(
        style: {
          "table": Style(width: 5000)
        },
        data: """<table width="2000px">
 <tr>
  <td colspan="2" style="border:2px solid black">Some other text</td>
  <td style="border:2px solid black">Some text</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
</table>""",)

Expected behavior:

Screenshot 2022-09-28 at 7 55 58 PM

Screenshots:

Device details and Flutter/Dart/flutter_html versions: Flutter version: 2.5.3 Dart version: 2.14.4 flutter_html: 2.2.1

Stacktrace/Logcat

Additional info:

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

Sub6Resources commented 1 year ago

Noted, thank you! We're working through a chunk of issues regarding table. Have you tried this in version 3.0.0-alpha.5?

YoofiBP commented 1 year ago

Noted, thank you! We're working through a chunk of issues regarding table. Have you tried this in version 3.0.0-alpha.5?

Yhup. Weirdly it does not render my table. Shows some general TABLE SECTION text

Screenshot 2022-10-02 at 4 36 42 PM

flutter_html: ^3.0.0-alpha.5

erickok commented 1 year ago

@YoofiBP you forgot to include the dependency on flutter_html_table

YoofiBP commented 1 year ago

flutter_html_table

Apologies:

flutter_html_table: ^3.0.0-alpha.3

erickok commented 1 year ago

Yes but you also need flutter_html_table, as per 3.0 the library is modularised.

YoofiBP commented 1 year ago

@erickok Yes I have flutter_html_table included and have implementation it as below:

Html(data: """<table width="2000px">
 <tr>
  <td colspan="2" style="border:2px solid black">Some other text</td>
  <td style="border:2px solid black">Some text</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
 <tr>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
  <td style="border:2px solid black">Hello</td>
 </tr>
</table>""",
    customRenders: {
      tableMatcher(): tableRender()
    },)

It still looks the same after including this

flutter_html_table: ^3.0.0-alpha.3

Rafal-Okuniewski commented 1 year ago

Hi I suppose I have the same problem. I am using version: flutter_html_table: 3.0.0-alpha.3

When I try to recreate the table from html I get the text value: TABLE SECTION

Adding to the dependency: flutter_html_table and setting:

 customRenders: {
   tableMatcher(): { tableRender(),
},

causes the table to appear but it does not display correctly to put it lightly

Sub6Resources commented 1 year ago

I was able to reproduce your error. There are currently a lot of open issues regarding tables, as they are quite difficult to properly implement in Flutter. This has been added to the queue and I'll take a closer look at it!