Last updated:
0 purchases
async table
Flutter Async Table #
A convenience package over PaginatedDataTable optimized for fetching items asynchronously.
Features #
AsyncTableWidget<T> that wraps a PaginatedDataTable
AsyncTableSource<T> that extends a DataTableSource
Getting started #
Add the package as a dependency in pubspec.yaml
dart pub add async_table
copied to clipboard
Usage #
//An optional wrapper to handle rowsPerPage
RowsPerPageWrapper(
initialRowsPerPage: initialrowsPerPage,
builder: (context, rowsPerPage, setRowsPerPage) {
return AsyncTableWidget<T>(
requestItems: (offset, rowsPerPage) async {
//send a request to the server here
},
//pass rowsPerPage, availableRowsPerPage, onRowsPerPageChanged
rowsPerPage: rowsPerPage,
onRowsPerPageChanged: setRowsPerPage,
//define the columns, and how each column builds the cell
columns: [
AsyncTableColumnDef(
cellBuilder: (context, item) => DataCell(Text(item.id)),
column: const DataColumn(label: Text('Id')),
),
AsyncTableColumnDef(
cellBuilder: (context, item) => DataCell(Text(item.title)),
column: const DataColumn(label: Text('Title')),
),
],
//store the AsyncTableSource<T> after its creation.
initState: (value) => dataSrc = value,
);
}
);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.