Specifically, in _alignRowIndex():
|
int _alignRowIndex(int rowIndex, int rowsPerPage) { |
|
return ((rowIndex + 1) ~/ rowsPerPage) * rowsPerPage; |
|
} |
We'd expect that _alignRowIndex(9, 10) would return 0, but instead we get 10:
((rowIndex + 1) ~/ rowsPerPage) * rowsPerPage
= ((9 + 1) ~/ 10) * 10
= (10 ~/ 10) * 10
= 1 * 10
= 10
So attempting to go to the page containing the last row for that page actually puts us on the page after the one we'd expect.
My workaround — to preserve some sort of forward-compatibility once this is fixed — is to subtract 1 from rowIndex before passing it into goToPageWithRow(), but only if (rowIndex - 1) % rowsPerPage == 0. Basically: if (and only if) we're on the index that would cause the error, then we pretend we're on the index before it.
Specifically, in
_alignRowIndex():data_table_2/lib/src/paginated_data_table_2.dart
Lines 596 to 598 in 879f9ba
We'd expect that
_alignRowIndex(9, 10)would return0, but instead we get10:So attempting to go to the page containing the last row for that page actually puts us on the page after the one we'd expect.
My workaround — to preserve some sort of forward-compatibility once this is fixed — is to subtract 1 from
rowIndexbefore passing it intogoToPageWithRow(), but only if(rowIndex - 1) % rowsPerPage == 0. Basically: if (and only if) we're on the index that would cause the error, then we pretend we're on the index before it.