DataTable constructor
Creates a widget describing a data table.
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 must not be null.
The rows
argument must be a list of as many DataRow objects
as the table is to have rows, ignoring the leading heading row
that contains the column headings (derived from the columns
argument). There may be zero rows, but the rows argument must
not be null.
Each DataRow object in rows
must have as many DataCell
objects in the DataRow.cells list as the table has columns.
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.
Implementation
DataTable({
Key key,
@required this.columns,
this.sortColumnIndex,
this.sortAscending = true,
this.onSelectAll,
@required this.rows,
}) : assert(columns != null),
assert(columns.isNotEmpty),
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
assert(sortAscending != null),
assert(rows != null),
assert(!rows.any((DataRow row) => row.cells.length != columns.length)),
_onlyTextColumn = _initOnlyTextColumn(columns),
super(key: key);