buildCompactPathWithElement static method

String buildCompactPathWithElement(
  1. Element targetElement, {
  2. int maxDepth = 15,
})

Implementation

static String buildCompactPathWithElement(Element targetElement, {int maxDepth = 15}) {
  final List<String> path = [];
  int depth = 0;

  // Add target widget
  final targetWidget = targetElement.widget;
  path.add(_formatWidgetInfo(targetWidget));

  // Traverse ancestors with depth limit
  targetElement.visitAncestorElements((element) {
    if (depth >= maxDepth) return false;

    final widget = element.widget;

    if (widget.key != null || _isImportantWidgetType(widget)) {
      path.add(_formatWidgetInfo(widget));
      depth++;
    }

    return true;
  });

  return path.reversed.join(' > ');
}