AtreeonPaginatedDataTable constructor

AtreeonPaginatedDataTable({
  1. Key? key,
  2. Widget? header,
  3. List<Widget>? actions,
  4. required List<DataColumn> columns,
  5. int? sortColumnIndex,
  6. bool sortAscending = true,
  7. ValueSetter<bool?>? onSelectAll,
  8. double dataRowHeight = kMinInteractiveDimension,
  9. double headingRowHeight = 56.0,
  10. double horizontalMargin = 24.0,
  11. double columnSpacing = 56.0,
  12. bool showCheckboxColumn = true,
  13. bool showFirstLastButtons = false,
  14. int? initialFirstRowIndex = 0,
  15. ValueChanged<int>? onPageChanged,
  16. int rowsPerPage = defaultRowsPerPage,
  17. List<int> availableRowsPerPage = const <int>[defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10],
  18. ValueChanged<int?>? onRowsPerPageChanged,
  19. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  20. Color? arrowHeadColor,
  21. required DataTableSource source,
  22. double? checkboxHorizontalMargin,
  23. ScrollController? controller,
  24. bool? primary,
  25. required double fontSize,
  26. required double iconSize,
  27. required double footerHeight,
})

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 must not be null. The source should be a long-lived DataTableSource. The same source should be provided each time a particular AtreeonPaginatedDataTable widget is created; avoid creating a new DataTableSource with each new instance of the AtreeonPaginatedDataTable widget unless the data table really is to now show entirely different data from a new source.

The rowsPerPage and availableRowsPerPage must not be null (they both have defaults, though, so don't have to be specified).

Themed by DataTableTheme. DataTableThemeData.decoration is ignored. To modify the border or background color of the AtreeonPaginatedDataTable, use CardTheme, since a Card wraps the inner DataTable.

Implementation

AtreeonPaginatedDataTable({
  super.key,
  this.header,
  this.actions,
  required this.columns,
  this.sortColumnIndex,
  this.sortAscending = true,
  this.onSelectAll,
  this.dataRowHeight = kMinInteractiveDimension,
  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,
  required this.fontSize,
  required this.iconSize,
  required this.footerHeight,
})  : assert(actions == null || (actions != null && header != null)),
      assert(columns != null),
      assert(dragStartBehavior != null),
      assert(columns.isNotEmpty),
      assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
      assert(sortAscending != null),
      assert(dataRowHeight != null),
      assert(headingRowHeight != null),
      assert(horizontalMargin != null),
      assert(columnSpacing != null),
      assert(showCheckboxColumn != null),
      assert(showFirstLastButtons != null),
      assert(rowsPerPage != null),
      assert(rowsPerPage > 0),
      assert(() {
        if (onRowsPerPageChanged != null) {
          assert(availableRowsPerPage != null && availableRowsPerPage.contains(rowsPerPage));
        }
        return true;
      }()),
      assert(source != null),
      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.',
      );