buildCompactPath static method

String buildCompactPath(
  1. BuildContext context, {
  2. int maxDepth = 15,
})

Implementation

static String buildCompactPath(BuildContext context, {int maxDepth = 15}) {
  final List<String> path = [];
  int depth = 0;

  // Add current widget
  final currentWidget = context.widget;
  path.add(_formatWidgetInfo(currentWidget));

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

    final widget = element.widget;

    // Include widgets with keys or important widget types
    if (widget.key != null || _isImportantWidgetType(widget)) {
      path.add(_formatWidgetInfo(widget));
      depth++;
    }

    return true;
  });

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