TableView.builder constructor
- Key? key,
- bool? primary,
- Axis mainAxis = Axis.vertical,
- ScrollableDetails horizontalDetails = const ScrollableDetails.horizontal(),
- ScrollableDetails verticalDetails = const ScrollableDetails.vertical(),
- double? cacheExtent,
- DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.none,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
- Clip clipBehavior = Clip.hardEdge,
- int pinnedRowCount = 0,
- int pinnedColumnCount = 0,
- int? columnCount,
- int? rowCount,
- required TableSpanBuilder columnBuilder,
- required TableSpanBuilder rowBuilder,
- 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,
),
);