inspect static method

Map<String, dynamic> inspect()

Recorre el árbol completo y retorna un JSON con todos los widgets que contienen datos relevantes para testing.

El JSON incluye:

  • timestamp: cuándo se capturó
  • widget_count: cantidad de widgets encontrados
  • widgets: lista de entradas, cada una con type, depth, y datos según el tipo (value, label, enabled, key, x, y, w, h)

Implementation

static Map<String, dynamic> inspect() {
  final root = WidgetsBinding.instance.rootElement;
  if (root == null) {
    return {
      'timestamp': DateTime.now().toUtc().toIso8601String(),
      'widget_count': 0,
      'widgets': <Map<String, dynamic>>[],
      'error': 'rootElement not available',
    };
  }

  final result = <Map<String, dynamic>>[];
  _walk(root, 0, result);

  return {
    'timestamp': DateTime.now().toUtc().toIso8601String(),
    'widget_count': result.length,
    'widgets': result,
  };
}