Skip to content

Temporary fix for irregular table rows #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

tneotia
Copy link
Contributor

@tneotia tneotia commented Oct 25, 2020

Possible temporary fix for #242 . Definitely needs testing, but in two test cases this worked fine.

Basically what I did was find the row(s) that had the most number of elements, and store their length.
Then, just before building the table, create a list of empty containers that corresponds to the difference between the length of the row being built and the length of the longest row(s).
Finally, attach that empty container list into the TableRow children property to avoid the irregular sizing error.

I left my print statements in for debugging if this solution doesn't work for certain cases.

@erickok
Copy link
Contributor

erickok commented Oct 26, 2020

I am hesitant to merge this, as it only fixes the odd case where not all columns are supplied in the html, yet just filling those missing cells with empty space is sufficient. It does not implement actual colspan support.

@tneotia
Copy link
Contributor Author

tneotia commented Oct 26, 2020

Yep that's why I labeled it as temporary. As far as I know, implementing colspan and rowspan will be impossible in flutter or we will have to create a custom widget implementation with the basic row and column widgets. I would leave this open and whoever needs this fix can use this branch in their pubspec

@tneotia
Copy link
Contributor Author

tneotia commented Oct 26, 2020

I tried to give this another shot using this package but I just could not figure out how to give each element the colspan and rowspan attribute. In the tree, the td has these attributes but I wanted to apply that data to the text within the td because that is going to be used to build the widget. I am also struggling with how to figure out which row/column each element is in.

These could be super trivial and I may be overthinking them, if someone else wants to give it a go, feel free!

@erickok
Copy link
Contributor

erickok commented Nov 19, 2020

I have tried using flutter_layout_grid as well, but that library doesn't seem to support intrinsic heights at all (despite claiming otherwise). Even their examples would not render on mobile Flutter for me, always throwing 'RenderConstrainedBox object was given an infinite size during layout' errors. 🤷

Using Flutter's Rows and Columns could work but that'd require quite some wrapping of rows/columns inside those rows/columns... very fair from ideal. flutter_html < 1.0 did do this, but only supported colspan, not rowspan.

I considered flutter_staggered_grid_view but that really works just when it is it's own scroll container.

spannable_grid looked promising too, but it actually fixes every cell in the grid to be rectangular.

The Flutter isssue asking for colspan/rowspan support is totally dormant. It also doesn't mention any 3th party alternatives.

😡

I guess we have to build something custom...

@ryan-berger
Copy link
Contributor

@erickok can this be closed due to your other PR that I just merged?

@tneotia
Copy link
Contributor Author

tneotia commented Jan 4, 2021

Not Eric but yes his solution which you merged is miles better than this one. Closing...

@tneotia tneotia closed this Jan 4, 2021
@tneotia tneotia deleted the temp_fix_irregular_row_lengths branch January 4, 2021 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants