getAllWidgetDetails static method

List<Map<String, dynamic>> getAllWidgetDetails(
  1. num scaleX,
  2. num scaleY
)

======== Your existing public API (unchanged shapes) ========

Implementation

//called in Screenshot
static List<Map<String, dynamic>> getAllWidgetDetails(num scaleX, num scaleY) {
  NLogger.i("Getting all widget details with scaleX: $scaleX, scaleY: $scaleY");
  final out = <Map<String, dynamic>>[];

  _entries.forEach((label, _) {
    final box = _resolveRenderBox(label);
    if (box == null || !box.hasSize) return;

    final pos = _globalTopLeft(box);
    final size = box.size;

    // ✅ Skip widgets with NaN or Infinite position/size values
    if (pos.dx.isNaN ||
        pos.dy.isNaN ||
        pos.dx.isInfinite ||
        pos.dy.isInfinite ||
        size.width.isNaN ||
        size.height.isNaN ||
        size.width.isInfinite ||
        size.height.isInfinite) {
      NLogger.w("Skipping widget $label due to invalid position/size values: "
          "pos=($pos), size=($size)");

    }
    else{
      out.add({
        'name': label,
        'id': label,
        'x': pos.dx * scaleX,
        'y': pos.dy * scaleY,
        'width': size.width * scaleX,
        'height': size.height * scaleY,
        'props': const {}, // kept for backward JSON compatibility; always empty
      });
    }


  });

  NLogger.i("Found ${out.length} widget details");
  NLogger.i("printing ${out}");
  return out;
  // Note: one row per *label*. If two widgets share a label, only the latest
  // registration exists (previous was replaced at register time).
}