Open francois-robert opened 7 months ago
Is there a way to have selected rows when creating table with AsyncDataTableSource? I tried to pass selected at true on every DataRow2 within getRows() function but it does nothing.
selected
Any idea ?
@override Future<AsyncRowsResponse> getRows(int startIndex, int count) async { final (items, paging) = await context.read<C>().fetchWithPaging(offset: startIndex, pageSize: count); this.items = items ?? []; if (items == null || paging == null) return AsyncRowsResponse(0, []); return AsyncRowsResponse( paging.total ?? 0, items .map( (item) => DataRow2( key: ValueKey<int>(item.hashCode), selected: true, onSelectChanged: selectable ? (value) => performSelectChanged(item, value) : null, color: color == null ? null : color!(item), cells: buildCells(context, item, this).map((e) => DataCell(Center(child: e))).toList(), ), ) .toList(), ); }
AsyncDataTableSource abstract class has own logic for selection and setting selected: true, in the AsyncRowsResponse is ignored.
AsyncDataTableSource
selected: true,
AsyncRowsResponse
If you happen to submit a PR with a fix for that - I am happy to review.
Is there a way to have selected rows when creating table with AsyncDataTableSource? I tried to pass
selected
at true on every DataRow2 within getRows() function but it does nothing.Any idea ?