flutter_html
flutter_html copied to clipboard
[caution] table nested is not supported : )
As the title points out, flutter_html won't support table nesting.
And I do not know how to solve it.
Without looking into this, I guess flutter_layout_grid doesn't support nested tables. I'm not sure why the necessarily is so, though.
Hmm actually flutter_layout_grid support it just fine. I am not sure where you got this error, but in my test the only reason this doesn't work (on master branch) is because of we try to determine via LayoutBuilder if the table is in a horizontally unbounded or bounded widget, but then LayoutBuilder does not support returning intrinsic dimensions
. Needs more investigation.
Is there a reason for using the LayoutBuilder? For me, tables just render fine when removing it...
Yes, it is used to determine if the table is in a bounded layout. Because if it is in an unbounded layout we cant support percentage based column sizes and have to set different column constraints accordingly.
I have tried to find a solution but failed so far.
I experimented with this a little. It seems the nested table is the one that throws the error. Here's something I tried that worked:
bool hasTable = element?.parent?.localName == 'td';
return Container(
margin: style.margin,
padding: style.padding,
decoration: BoxDecoration(
color: style.backgroundColor,
border: style.border,
),
width: style.width,
height: style.height,
child: hasTable ? _layoutCells(context, null)
: LayoutBuilder(builder: (_, constraints) => _layoutCells(context, constraints)),
);
and change !constraints?.hasBoundedWidth
to !(constraints?.hasBoundedWidth ?? false)
so BoxConstraints
can be null
.
Of course, this doesn't work if the tree is, say td > div > table
, but its a start. Maybe something like this can be used to solve this issue?
Hmm maybe. The problem we have here is that to know if we can use percentage-based column widths, I need to know ifd 'we' are in a horizontally bounded container or not. I was using LayoutBuilder for this purpose but indeed it breaks (among other things) embedded tables.
If anyone knows a better way to determine if at that spot we are in a horizontally bounded layout or not, that would solve the source problem.
I fear that’s impossible in the “Widget”-world, you need to do it in the “RenderBox”-world afaik.
Yes, I agree. And I am not feeling very at my place yet there. I should give it a try though.
any solution for this?
Sorry, not at the moment. I tried again yesterday and couldn't come up with a solution yet. Will have to read more about flutter and come back to this.