buildTableWhenReady method

Widget buildTableWhenReady(
  1. BoxConstraints constraints, {
  2. bool shouldClearRow = false,
})

Original build method from the Flutter PaginatedDataTable

Implementation

Widget buildTableWhenReady(BoxConstraints constraints, {bool shouldClearRow = false}) {
  final themeData = Theme.of(context);
  final footerTextStyle = themeData.textTheme.caption;
  if(shouldClearRow) {
    _rows.clear();
  }
  assert(debugCheckHasMaterialLocalizations(context));
  final headerWidgets = _buildHeaders();
  final footerWidgets = _buildFooters();
  return Card(
    key: ValueKey(tableKey),
    semanticContainer: false,
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        if (headerWidgets.isNotEmpty)
          Semantics(
            container: true,
            child: DefaultTextStyle(
              // These typographic styles aren't quite the regular ones. We pick the closest ones from the regular
              // list and then tweak them appropriately.
              // See https://material.io/design/components/data-tables.html#tables-within-cards
              style: _selectedRowCount > 0
                  ? themeData.textTheme.subtitle1!
                      .copyWith(color: themeData.colorScheme.secondary)
                  : themeData.textTheme.headline6!
                      .copyWith(fontWeight: FontWeight.w400),
              child: IconTheme.merge(
                data: const IconThemeData(
                  opacity: 0.54,
                ),
                child: Ink(
                  height: 64.0,
                  color: _selectedRowCount > 0
                      ? themeData.secondaryHeaderColor
                      : null,
                  child: Padding(
                    padding: EdgeInsetsDirectional.only(
                        start: _startPadding, end: 14.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: headerWidgets,
                    ),
                  ),
                ),
              ),
            ),
          ),
        SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          dragStartBehavior: widget.dragStartBehavior,
          child: ConstrainedBox(
            constraints: BoxConstraints(minWidth: constraints.maxWidth),
            child: DataTable(
              columns: widget.columns,
              sortColumnIndex: widget.sortColumnIndex,
              sortAscending: widget.sortAscending,
              onSelectAll: widget.onSelectAll,
              // Make sure no decoration is set on the DataTable
              // from the theme, as its already wrapped in a Card.
              dataRowHeight: widget.dataRowHeight,
              headingRowHeight: widget.headingRowHeight,
              horizontalMargin: widget.horizontalMargin,
              columnSpacing: widget.columnSpacing,
              showCheckboxColumn: widget.showCheckboxColumn,
              showBottomBorder: true,
              rows: _getRows(_firstRowIndex, widget.rowsPerPage),
            ),
          ),
        ),
        DefaultTextStyle(
          style: footerTextStyle!,
          child: IconTheme.merge(
            data: const IconThemeData(
              opacity: 0.54,
            ),
            child: SizedBox(
              height: 56.0,
              child: SingleChildScrollView(
                dragStartBehavior: widget.dragStartBehavior,
                scrollDirection: Axis.horizontal,
                reverse: true,
                child: Row(
                  children: footerWidgets,
                ),
              ),
            ),
          ),
        ),
      ],
    ),
  );
}