maxim-saplin / data_table_2

In-place substitute for Flutter's DataTable and PaginatedDataTable with fixed/sticky header and extra features
https://pub.dev/packages/data_table_2
BSD 3-Clause "New" or "Revised" License
202 stars 135 forks source link

AsyncDataTableSource.selectAll() seems that not update _selectionRowKeys correctly #275

Open MarcoLuciani-94 opened 4 months ago

MarcoLuciani-94 commented 4 months ago

in a AsyncPaginatedDataTable2 with AsyncDataTableSource class, seems that on selectAll(), function don't insert all Keys inside _selectionRowKeys object.

for example, take a table with 7 elements:

AsyncPaginatedDataTable2(
                    empty:Center(
                    child: Container(
                        padding: const EdgeInsets.all(20),
                        color: Colors.grey[200],
                        child: const Text('No data'))),
                    columnSpacing: 12,
                    horizontalMargin: 12,
                    columns: columns,
                    loading: _Loading(),
                    onSelectAll: (select) {
                      if (select != null && select) {
                        dataSource!.selectAll();
                      }
                      if (select != null && !select) {
                        dataSource!.deselectAll();
                      }},
                    source: dataSource!,
                    rowsPerPage: 5, // Number of rows per page
                    availableRowsPerPage: const [2, 5, 10, 30, 100],
                    showCheckboxColumn: true,
                    showFirstLastButtons: true,
                    checkboxHorizontalMargin: 12,
                    wrapInCard: false,
                    renderEmptyRowsInTheEnd: false,
                    controller: _controller,
                    ),

i obtain those results:

print(dataSource!.selectedRowCount); \\ 7
  print(dataSource!.selectionRowKeys); \\ 0

looking on https://github.com/maxim-saplin/data_table_2/blob/1919e3d70e196c2cfe197147ef5f5ba3491f4266/lib/src/async_paginated_data_table_2.dart#L120

there is:

 void selectAll() {
    _selectionState = SelectionState.exclude;
    _selectionRowKeys.clear();
    notifyListeners();
  }

is correct that system clear the list, but maybe after it maybe need to add all element again? or there is another approach or method to obtain Keys list? On UI side, everything work fine and also count work. Thanks Marco