getAllWidgetDetails static method

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

Implementation

static List<Map<String, dynamic>> getAllWidgetDetails(
  num scaleX,
  num scaleY,
) {
  NLogger.i(
    "Getting all widget details with scaleX: $scaleX, scaleY: $scaleY",
  );
  List<Map<String, dynamic>> details = [];
  _widgetKeys.forEach((label, key) {
    final RenderBox? box =
        key.currentContext?.findRenderObject() as RenderBox?;

    if (box != null) {
      final size = box.size;
      final position = box.localToGlobal(Offset.zero);

      details.add({
        'name': label,
        'id': label,
        'x': position.dx.toInt() * scaleX,
        'y': position.dy.toInt() * scaleY,
        'width': size.width.toInt() * scaleX,
        'height': size.height.toInt() * scaleY,
        'props': {},
      });
    }
  });

  NLogger.i("Found ${details.length} widget details");

  return details;
}