TableView.builder constructor

TableView.builder({
  1. Key? key,
  2. bool? primary,
  3. Axis mainAxis = Axis.vertical,
  4. ScrollableDetails horizontalDetails = const ScrollableDetails.horizontal(),
  5. ScrollableDetails verticalDetails = const ScrollableDetails.vertical(),
  6. double? cacheExtent,
  7. DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.none,
  8. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  9. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  10. Clip clipBehavior = Clip.hardEdge,
  11. int pinnedRowCount = 0,
  12. int pinnedColumnCount = 0,
  13. int? columnCount,
  14. int? rowCount,
  15. required TableSpanBuilder columnBuilder,
  16. required TableSpanBuilder rowBuilder,
  17. required TableViewCellBuilder cellBuilder,
})

Creates a TableView of widgets that are created on demand.

This constructor is appropriate for table views with a large number of cells because the cellbuilder is called only for those cells that are actually visible.

This constructor generates a TableCellBuilderDelegate for building children on demand using the required cellBuilder, columnBuilder, and rowBuilder.

For infinite rows and columns, omit providing columnCount or rowCount. Returning null from the columnBuilder or rowBuilder will terminate the row or column at that index, representing the end of the table in that axis. In this scenario, until the potential end of the table in either dimension is reached by returning null, the ScrollPosition.maxScrollExtent will reflect double.infinity. This is because as the table is built lazily, it will not know the end has been reached until the ScrollPosition arrives there. This is similar to returning null from ListView.builder to signify the end of the list.

Implementation

TableView.builder({
  super.key,
  super.primary,
  super.mainAxis,
  super.horizontalDetails,
  super.verticalDetails,
  super.cacheExtent,
  super.diagonalDragBehavior = DiagonalDragBehavior.none,
  super.dragStartBehavior,
  super.keyboardDismissBehavior,
  super.clipBehavior,
  int pinnedRowCount = 0,
  int pinnedColumnCount = 0,
  int? columnCount,
  int? rowCount,
  required TableSpanBuilder columnBuilder,
  required TableSpanBuilder rowBuilder,
  required TableViewCellBuilder cellBuilder,
})  : assert(pinnedRowCount >= 0),
      assert(rowCount == null || rowCount >= 0),
      assert(rowCount == null || rowCount >= pinnedRowCount),
      assert(columnCount == null || columnCount >= 0),
      assert(pinnedColumnCount >= 0),
      assert(columnCount == null || columnCount >= pinnedColumnCount),
      super(
        delegate: TableCellBuilderDelegate(
          columnCount: columnCount,
          rowCount: rowCount,
          pinnedColumnCount: pinnedColumnCount,
          pinnedRowCount: pinnedRowCount,
          cellBuilder: cellBuilder,
          columnBuilder: columnBuilder,
          rowBuilder: rowBuilder,
        ),
      );