boundsOf method
Global rect and view size of node (an inspector node needs no glintId), or null when it cannot be measured.
Implementation
Future<({double x, double y, double w, double h, double vw, double vh})?> boundsOf(
Scene scene, SceneNode node) async {
try {
await _runtime.setInspectorSelection(
inspectorId: node.inspectorId,
groupName: scene.fullGroupName ?? scene.groupName,
);
final json = await _runtime.evaluateString(GeometryExpr.build(), rethrowErrors: true);
if (json == null) return null;
final d = _decode(json, 'bounds');
if (d['gx'] == null || d['gy'] == null) return null;
final w = (d['bw'] as num).toDouble(), h = (d['bh'] as num).toDouble();
return (
x: (d['gx'] as num).toDouble() - w / 2,
y: (d['gy'] as num).toDouble() - h / 2,
w: w,
h: h,
vw: (d['vw'] as num).toDouble(),
vh: (d['vh'] as num).toDouble(),
);
} on Object {
return null;
}
}