Table constructor

  1. {Key? key,
  2. List<TableRow> children = const <TableRow>[],
  3. Map<int, TableColumnWidth>? columnWidths,
  4. TableColumnWidth defaultColumnWidth = const FlexColumnWidth(),
  5. TextDirection? textDirection,
  6. TableBorder? border,
  7. TableCellVerticalAlignment defaultVerticalAlignment =,
  8. TextBaseline? textBaseline}

Creates a table.


  this.children = const <TableRow>[],
  this.defaultColumnWidth = const FlexColumnWidth(),
  this.defaultVerticalAlignment =,
  this.textBaseline, // NO DEFAULT: we don't know what the text's baseline should be
}) : assert(defaultVerticalAlignment != TableCellVerticalAlignment.baseline || textBaseline != null, 'textBaseline is required if you specify the defaultVerticalAlignment with TableCellVerticalAlignment.baseline'),
     assert(() {
       if (children.any((TableRow row1) => row1.key != null && children.any((TableRow row2) => row1 != row2 && row1.key == row2.key))) {
         throw FlutterError(
           'Two or more TableRow children of this Table had the same key.\n'
           'All the keyed TableRow children of a Table must have different Keys.',
       return true;
     assert(() {
       if (children.isNotEmpty) {
         final int cellCount = children.first.children.length;
         if (children.any((TableRow row) => row.children.length != cellCount)) {
           throw FlutterError(
             'Table contains irregular row lengths.\n'
             'Every TableRow in a Table must have the same number of children, so that every cell is filled. '
             'Otherwise, the table will contain holes.',
         if (children.any((TableRow row) => row.children.isEmpty)) {
           throw FlutterError(
             'One or more TableRow have no children.\n'
             'Every TableRow in a Table must have at least one child, so there is no empty row. ',
       return true;
     _rowDecorations = children.any((TableRow row) => row.decoration != null)
                            ?<Decoration?>((TableRow row) => row.decoration).toList(growable: false)
                            : null {
  assert(() {
    final List<Widget> flatChildren = children.expand<Widget>((TableRow row) => row.children).toList(growable: false);
    return !debugChildrenHaveDuplicateKeys(this, flatChildren, message:
      'Two or more cells in this Table contain widgets with the same key.\n'
      'Every widget child of every TableRow in a Table must have different keys. The cells of a Table are '
      'flattened out for processing, so separate cells cannot have duplicate keys even if they are in '
      'different rows.',