material_table_view icon indicating copy to clipboard operation
material_table_view copied to clipboard

Dynamic row hight and/or column width

Open MuKhAlm opened this issue 1 year ago • 4 comments

Description

There is no seemingly good way to set row hight and column width dynamically according to the requirements of their contents (in the same way DataTable does).

MuKhAlm avatar Jul 24 '24 20:07 MuKhAlm

Yes, currently there is no way of sizing the cells by their intrinsic size. This was a deliberate choice at the early stage of development as the performance implications of this feature are unacceptable when displaying large amounts of data which is one of a primary objectives of this library. Although I've considered adding these features and here are my thoughts.

Support for sizing rows shouldn't be too difficult to get done. For that we could use existing Flutter mechanisms that will perform double pass layout for us. Building and laying out every cell in a row will be nessesary to prevent sudden height changes during horizontal scrolling when cell of a larger height comes into or out of view. We will need a way of setting wiggle distance for vertical dividers too.

Support for sizing columns on the other hand will be way more difficult to get done. Currently the column layout is calculated at the widget level. To calculate intrinsic column with we will need to do it on a render object level in a layout pass as we will need constructed render objects to measure before laying them out. Doing so will require a lot of refactoring and testing of every single feature to prevent regressions. Additionally, every single cell in the column will need to be built and measured for the same reasons as in the case of rows.

Whenever both are used together the entire table will need to be constructed whenever it is first built or rebuilt. If there is any way of avoiding that, one should take it. However, I can see that it's not always possible.

Although I'm not opposed to adding these features I can't promise I will have time to spare on them.

NikolayNIK avatar Jul 25 '24 03:07 NikolayNIK

That make sense. I didn't take displaying huge amount of data into consideration.

Thank you for taking the time to respond

MuKhAlm avatar Jul 25 '24 07:07 MuKhAlm

I'll reopen this issue just to not let the idea fade away

NikolayNIK avatar Jan 26 '25 12:01 NikolayNIK

Please check https://github.com/NikolayNIK/material_table_view/pull/52

yerkejs avatar Jul 22 '25 16:07 yerkejs