extractDetails method
void
extractDetails(})
Implementation
void extractDetails(BuildContext? context, Map<String, dynamic> details,
num xFactor, num yFactor,
{String parentKey = 'root'}) {
if (context == null) return;
RenderBox box;
Offset position = Offset.zero;
Size size = Size.zero;
try {
box = context.findRenderObject() as RenderBox;
if (box is RenderBox) {
// Now you're safe to proceed with your RenderBox operations
size = box.size;
position = box.localToGlobal(Offset.zero);
// Continue with your logic...
} else {
// Handle the case where the renderObject is not a RenderBox
// This might involve skipping the operation or handling differently
}
} catch (e) {
print(e);
}
String key = context.widget.key?.toString() ?? 'no-key';
var widgetDetail = {
'name': '$parentKey/$key',
'componentId': DateTime.now().millisecondsSinceEpoch,
'x': position.dx.toInt() * xFactor,
'y': position.dy.toInt() * yFactor,
'width': size.width.toInt() * xFactor,
'height': size.height.toInt() * yFactor,
};
details['$parentKey/$key'] = widgetDetail;
if (key != 'no-key') {
WidgetDetailsService.addWidgetDetails(key, widgetDetail);
}
context.visitChildElements((Element element) {
extractDetails(
element,
details,
xFactor,
yFactor,
parentKey: '$parentKey/$key',
);
});
}