ReorderableTable constructor

ReorderableTable({
  1. required ReorderCallback onReorder,
  2. List<ReorderableTableRow> children = const <ReorderableTableRow>[],
  3. Map<int, TableColumnWidth>? columnWidths,
  4. TableColumnWidth defaultColumnWidth = const FlexColumnWidth(1.0),
  5. TextDirection? textDirection,
  6. TableBorder? border,
  7. TableCellVerticalAlignment defaultVerticalAlignment = TableCellVerticalAlignment.top,
  8. TextBaseline? textBaseline,
  9. Widget? header,
  10. Widget? footer,
  11. DecorateDraggableFeedback? decorateDraggableFeedback,
  12. NoReorderCallback? onNoReorder,
  13. Duration? reorderAnimationDuration,
  14. Duration? scrollAnimationDuration,
  15. bool ignorePrimaryScrollController = false,
  16. Key? key,
})

Creates a reorderable table.

The children, defaultColumnWidth, and defaultVerticalAlignment arguments must not be null.

Implementation

ReorderableTable({
  required this.onReorder,
  this.children = const <ReorderableTableRow>[],
  this.columnWidths,
  this.defaultColumnWidth = const FlexColumnWidth(1.0),
  this.textDirection,
  this.border,
  this.defaultVerticalAlignment = TableCellVerticalAlignment.top,
  this.textBaseline,
  this.header,
  this.footer,
  this.decorateDraggableFeedback,
  this.onNoReorder,
  this.reorderAnimationDuration,
  this.scrollAnimationDuration,
  this.ignorePrimaryScrollController = false,
  Key? key,
})  : assert(() {
        if (children.any((ReorderableTableRow row1) =>
            row1.key != null &&
            children.any((ReorderableTableRow row2) =>
                row1 != row2 && row1.key == row2.key))) {
          throw FlutterError(
              'Two or more ReorderableTableRow children of this Table had the same key.\n'
              'All the keyed ReorderableTableRow children of a Table must have different Keys.');
        }
        return true;
      }()),
//      assert(() {
//        if (children.isNotEmpty) {
//          final int cellCount = children.first.children.length;
//          if (children.any((ReorderableTableRow row) => row.children.length != cellCount)) {
//            throw FlutterError(
//              'Table contains irregular row lengths.\n'
//                'Every ReorderableTableRow in a Table must have the same number of children, so that every cell is filled. '
//                'Otherwise, the table will contain holes.'
//            );
//          }
//        }
//        return true;
//      }()),

      super(key: key) {
  assert(() {
    final List<Widget> flatChildren = children
        .expand<Widget>((ReorderableTableRow row) => row.children)
        .toList(growable: false);
    if (debugChildrenHaveDuplicateKeys(this, flatChildren)) {
      throw FlutterError(
          '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.');
    }
    return true;
  }());
}