RenderTable constructor
- int? columns,
- int? rows,
- Map<
int, TableColumnWidth> ? columnWidths, - TableColumnWidth defaultColumnWidth = const FlexColumnWidth(),
- required TextDirection textDirection,
- TableBorder? border,
- List<
Decoration?> ? rowDecorations, - ImageConfiguration configuration = ImageConfiguration.empty,
- TableCellVerticalAlignment defaultVerticalAlignment = TableCellVerticalAlignment.top,
- TextBaseline? textBaseline,
- List<
List< ? children,RenderBox> >
Creates a table render object.
columns
must either be null or non-negative. Ifcolumns
is null, the number of columns will be inferred from length of the first sublist ofchildren
.rows
must either be null or non-negative. Ifrows
is null, the number of rows will be inferred from thechildren
. Ifrows
is not null, thenchildren
must be null.children
must either be null or contain lists of all the same length. ifchildren
is not null, thenrows
must be null.columnWidths
may be null, in which case it defaults to an empty map.
Implementation
RenderTable({
int? columns,
int? rows,
Map<int, TableColumnWidth>? columnWidths,
TableColumnWidth defaultColumnWidth = const FlexColumnWidth(),
required TextDirection textDirection,
TableBorder? border,
List<Decoration?>? rowDecorations,
ImageConfiguration configuration = ImageConfiguration.empty,
TableCellVerticalAlignment defaultVerticalAlignment = TableCellVerticalAlignment.top,
TextBaseline? textBaseline,
List<List<RenderBox>>? children,
}) : assert(columns == null || columns >= 0),
assert(rows == null || rows >= 0),
assert(rows == null || children == null),
_textDirection = textDirection,
_columns = columns ?? (children != null && children.isNotEmpty ? children.first.length : 0),
_rows = rows ?? 0,
_columnWidths = columnWidths ?? HashMap<int, TableColumnWidth>(),
_defaultColumnWidth = defaultColumnWidth,
_border = border,
_textBaseline = textBaseline,
_defaultVerticalAlignment = defaultVerticalAlignment,
_configuration = configuration {
_children = <RenderBox?>[]..length = _columns * _rows;
this.rowDecorations = rowDecorations; // must use setter to initialize box painters array
children?.forEach(addRow);
}