Open InstantlyMoist opened 9 months ago
Anyone looking for a temporary workaround, you could use this piece of code to 'fix' your html string. It's based on the 'html' library and un-nests
tags and
static String fixHtml(String html) {
var inputHtml = parseFragment(html);
// Select all table elements containing a <p> tag, and unwrap the <p> tag from the table elements
inputHtml.querySelectorAll("th p, td p").forEach(
(element) => element.replaceWith(
replaceElementWithTag(element, "span"),
),
);
// Push li one layer deeper
inputHtml.querySelectorAll(
"th > ul > li,"
"th > ol > li,"
"td > ul > li,"
"td > ol > li").forEach(
(element) => element.replaceWith(
replaceElementWithTag(element, "span"),
),
);
inputHtml.querySelectorAll(
"th > ul,"
"th > ol,"
"td > ul,"
"td > ol").forEach(
(element) => element.replaceWith(
replaceElementWithTag(element, "span"),
),
);
return inputHtml.outerHtml;
}
static Element replaceElementWithTag(Element element, String replacement) {
return Element.html(
"<$replacement>${element.innerHtml}</$replacement>",
);
}
Describe the bug: When using a table widget with the
flutter_html_table
package, it overflows. This is with or without sized boxes or SingleChildScrollView. Both in an attempt to catch the enormous size.HTML to reproduce the issue:
Html
widget configuration:Device details and Flutter/Dart/
flutter_html
versions: flutter_html: Tried both the latest beta, and the fix branchFlutter 3.16.9 • channel stable • https://github.com/flutter/flutter.git Framework • revision 41456452f2 (3 weeks ago) • 2024-01-25 10:06:23 -0800 Engine • revision f40e976bed Tools • Dart 3.2.6 • DevTools 2.28.5