flutter PaginatedDataTable2: hidden empty rows occupy space

115 views Asked by At
PaginatedDataTable2(
   renderEmptyRowsInTheEnd: false,
   columns: _columns,
   source: _source,
)

The empty rows are not rendered, but occupy space. How to remove the empty space?

1

There are 1 answers

0
TrueKing On

I surmise that you are using the data_table_2 package.

PaginatedDataTable2 does not give a default way of doing that. You would have to filter your list to remove entirely empty rows before making it into a source. You will have to provide some more code if you need help with that.

Additional Info

According to the readme,

Paginated table's by default add empty rows should the page be larger than the number of available rows, can be changed via renderEmptyRowsInTheEnd

This makes it clear that the named parameter renderEmptyRowsInTheEnd is not there to hide empty rows within the source list as according to the data provided, rather to remove all rendered rows which make up for the total expected rows for that page (this defaults to 10 unless otherwise specified).

So as we can observe below, the total dataset has 14 members, out of which 10 (by default) are being displayed on the page: Screenshot of 10/14 displayed data

Now, reducing the entire dataset to 6 will give us 4 additional empty rows at the end of the table as seen below: Screenshot of 6/6 displayed data when renderEmptyRowsInTheEnd is not set to false