buildDataColumns method

TreeRow? buildDataColumns(
  1. List<TreeRowNode> treeNodes,
  2. int rowIndex,
  3. List<HeaderRow> headerRowList, {
  4. int level = 0,
  5. List<int> parentIndexes = const [],
})

Builds data columns for the given treeNodes, rowIndex, and headerRowList.

Implementation

TreeRow? buildDataColumns(
  List<TreeRowNode> treeNodes,
  int rowIndex,
  List<hr.HeaderRow> headerRowList, {
  int level = 0,
  List<int> parentIndexes = const [],
}) {
  if (treeNodes.isEmpty || rowIndex < 0 || rowIndex >= treeNodes.length) {
    return null;
  }

  final allIndexes = [...parentIndexes, rowIndex];

  final sourceNode = treeNodes[rowIndex];
  final ValueNotifier<bool> isExpanded = ValueNotifier(sourceNode.isExpanded);

  final childrenLoaded = ValueNotifier<bool>(false);
  final childrenLoading = ValueNotifier<bool>(false);

  late final TreeRow row;
  row = TreeRow(
    level: level,
    maxLevel: maxLevel,
    uniqueKey: _rowKey(sourceNode, level, allIndexes),
    pathIndexes: allIndexes,
    rows: [],
    isExpanded: isExpanded,
    height: sourceNode.height,
    sourceNode: sourceNode,
    childrenLoaded: childrenLoaded,
    childrenLoading: childrenLoading,
    columns: sourceNode.columns.mapIndexed((columnIndex, column) {
      hc.HeaderColumn headerColumn = headerRowList[headerRowList.length - 1].columns[columnIndex];
      final sourceColumnIndex = headerColumn.sourceColumnIndex;

      return TreeColumn(
        widget: _buildDataColumn(
          sourceNode,
          () => row,
          sourceColumnIndex,
          isExpanded,
          childrenLoading,
          level,
        ),
        autoSizeWidget: sourceNode.columns[sourceColumnIndex].widget,
        autoSizeWidth: sourceNode.columns[sourceColumnIndex].autoSizeWidth,
        autoSizeWidthBuilder: sourceNode.columns[sourceColumnIndex].autoSizeWidthBuilder,
        filterValue: sourceNode.columns[sourceColumnIndex].filterValue,
        width: headerColumn.width,
        visible: headerColumn.visible,
        pinLeft: headerColumn.pinLeft,
        pinRight: headerColumn.pinRight,
      );
    }).toList(),
  );

  return row;
}