PaginatedDataTable constructor
- Key? key,
- Widget? header,
- List<
Widget> ? actions, - required List<
DataColumn> columns, - int? sortColumnIndex,
- bool sortAscending = true,
- ValueSetter<
bool?> ? onSelectAll, - @Deprecated('Migrate to use dataRowMinHeight and dataRowMaxHeight instead. ' 'This feature was deprecated after v3.7.0-5.0.pre.') double? dataRowHeight,
- double? dataRowMinHeight,
- double? dataRowMaxHeight,
- double headingRowHeight = 56.0,
- double horizontalMargin = 24.0,
- double columnSpacing = 56.0,
- bool showCheckboxColumn = true,
- bool showFirstLastButtons = false,
- int? initialFirstRowIndex = 0,
- ValueChanged<
int> ? onPageChanged, - int rowsPerPage = defaultRowsPerPage,
- List<
int> availableRowsPerPage = const <int>[defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10], - ValueChanged<
int?> ? onRowsPerPageChanged, - DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- Color? arrowHeadColor,
- required DataTableSource source,
- double? checkboxHorizontalMargin,
- ScrollController? controller,
- bool? primary,
- MaterialStateProperty<
Color?> ? headingRowColor, - bool showEmptyRows = true,
Creates a widget describing a paginated DataTable on a Card.
The header should give the card's header, typically a Text widget.
The columns argument must be a list of as many DataColumn objects as the table is to have columns, ignoring the leading checkbox column if any. The columns argument must have a length greater than zero and cannot be null.
If the table is sorted, the column that provides the current primary key should be specified by index in sortColumnIndex, 0 meaning the first column in columns, 1 being the next one, and so forth.
The actual sort order can be specified using sortAscending; if the sort order is ascending, this should be true (the default), otherwise it should be false.
The source should be a long-lived DataTableSource. The same source should be provided each time a particular PaginatedDataTable widget is created; avoid creating a new DataTableSource with each new instance of the PaginatedDataTable widget unless the data table really is to now show entirely different data from a new source.
Themed by DataTableTheme. DataTableThemeData.decoration is ignored. To modify the border or background color of the PaginatedDataTable, use CardTheme, since a Card wraps the inner DataTable.
Implementation
PaginatedDataTable({
super.key,
this.header,
this.actions,
required this.columns,
this.sortColumnIndex,
this.sortAscending = true,
this.onSelectAll,
@Deprecated(
'Migrate to use dataRowMinHeight and dataRowMaxHeight instead. '
'This feature was deprecated after v3.7.0-5.0.pre.',
)
double? dataRowHeight,
double? dataRowMinHeight,
double? dataRowMaxHeight,
this.headingRowHeight = 56.0,
this.horizontalMargin = 24.0,
this.columnSpacing = 56.0,
this.showCheckboxColumn = true,
this.showFirstLastButtons = false,
this.initialFirstRowIndex = 0,
this.onPageChanged,
this.rowsPerPage = defaultRowsPerPage,
this.availableRowsPerPage = const <int>[defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10],
this.onRowsPerPageChanged,
this.dragStartBehavior = DragStartBehavior.start,
this.arrowHeadColor,
required this.source,
this.checkboxHorizontalMargin,
this.controller,
this.primary,
this.headingRowColor,
this.showEmptyRows = true,
}) : assert(actions == null || (header != null)),
assert(columns.isNotEmpty),
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
assert(dataRowMinHeight == null || dataRowMaxHeight == null || dataRowMaxHeight >= dataRowMinHeight),
assert(dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null),
'dataRowHeight ($dataRowHeight) must not be set if dataRowMinHeight ($dataRowMinHeight) or dataRowMaxHeight ($dataRowMaxHeight) are set.'),
dataRowMinHeight = dataRowHeight ?? dataRowMinHeight,
dataRowMaxHeight = dataRowHeight ?? dataRowMaxHeight,
assert(rowsPerPage > 0),
assert(() {
if (onRowsPerPageChanged != null) {
assert(availableRowsPerPage.contains(rowsPerPage));
}
return true;
}()),
assert(!(controller != null && (primary ?? false)),
'Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. '
'You cannot both set primary to true and pass an explicit controller.',
);