buildTable method

Widget buildTable(
  1. BuildContext context
)

Implementation

Widget buildTable(BuildContext context) {
  return LayoutBuilder(
    builder: (context, outerConstraints) {
      final minWidth =
          widget.fitToAvailableWidth ? outerConstraints.maxWidth : MediaQuery.of(context).size.width - 100;

      return Theme(
        data: Theme.of(context).copyWith(
          scrollbarTheme: ScrollbarThemeData(
              thickness: WidgetStateProperty.all(widget.scrollbarThickness),
              radius: widget.scrollbarRadius,
              thumbVisibility: WidgetStateProperty.all(true),
              thumbColor: WidgetStatePropertyAll(ConectarDesignSystem.settings.primaryColor.withValues(alpha: 0.6))),
        ),
        child: Scrollbar(
          controller: scrollController,
          child: SingleChildScrollView(
            controller: scrollController,
            scrollDirection: Axis.horizontal,
            child: ConstrainedBox(
              constraints: BoxConstraints(minWidth: minWidth),
              child: DataTable(
                dividerThickness: 0.1,
                headingRowColor: WidgetStateProperty.all(
                  ConectarDesignSystem.settings.primaryColor.withAlpha(30),
                ),
                dataRowColor: widget.dataRowColor ??
                    WidgetStateProperty.resolveWith(
                      (Set<WidgetState> states) {
                        if (states.contains(WidgetState.selected)) {
                          return ConectarDesignSystem.settings.primaryColor.withValues(alpha: 0.08);
                        }
                        return null;
                      },
                    ),
                showCheckboxColumn: widget.showCheckboxColumn && hasSelectionFeature,
                onSelectAll: hasSelectionFeature ? widget.onSelectAll : null,
                dataRowMinHeight: widget.dataRowMinHeight,
                dataRowMaxHeight: widget.dataRowMaxHeight,
                showBottomBorder: widget.showBottomBorder,
                sortColumnIndex: getSortColumnIndex(),
                sortAscending: currentSort?.isAscending ?? true,
                columns: buildColumns(context),
                rows: buildRows(),
              ),
            ),
          ),
        ),
      );
    },
  );
}