maxWidth method

double maxWidth(
  1. List<Node<T>> nodes
)

Widest row across the whole tree (all descendants, regardless of expand state) plus the left content padding — a stable width independent of which nodes are currently expanded.

Implementation

double maxWidth(List<Node<T>> nodes) {
  // Merge the effective style once per tier when the tier has no per-node
  // resolver (the common case), instead of allocating a merged TextStyle for
  // every node. Tiers with a resolver keep resolving per node (exact).
  final tierStyle = <NodeType, TextStyle>{};
  TextStyle styleOf(Node<T> node) => _hasTextStyleResolver(node.type)
      ? _mergedStyle(node)
      : (tierStyle[node.type] ??= _mergedStyle(node));

  var widest = 0.0;
  void visit(List<Node<T>> list, int depth) {
    for (final node in list) {
      final w = _rowWidth(node, depth, styleOf(node));
      if (w > widest) widest = w;
      if (node.children.isNotEmpty) visit(node.children, depth + 1);
    }
  }

  visit(nodes, 0);
  return theme.spacingTheme.contentPadding.left + widest;
}