nativeScene function
The labelled or tappable nodes as a flat native scene in logical points.
Implementation
Scene nativeScene(Iterable<NativeNode> nodes, double dpr) {
final root = SceneNode(
depth: 0,
indexInParent: -1,
description: '_NativeRoot',
type: 'native',
inspectorId: '',
)..glintId = '_native_root';
final used = <String, int>{};
final kids = <SceneNode>[];
for (final n in nodes) {
if (n.label.isEmpty && !n.clickable) continue;
if (n.x2 <= n.x1 || n.y2 <= n.y1) continue;
final base = _slug(n.label.isNotEmpty ? n.label : n.cls);
final count = used.update(base, (v) => v + 1, ifAbsent: () => 1);
kids.add(SceneNode(
depth: 1,
indexInParent: kids.length,
description: n.cls,
type: 'native',
inspectorId: '',
widgetRuntimeType: n.cls,
textPreview: n.label.isEmpty ? null : n.label,
createdByLocalProject: true,
)
..glintId = count == 1 ? 'native_$base' : 'native_${base}_$count'
..isNativeEnabled = n.clickable
..axFrame = (x: n.x1 / dpr, y: n.y1 / dpr, w: (n.x2 - n.x1) / dpr, h: (n.y2 - n.y1) / dpr));
}
root.children = kids;
return Scene.native(root: root);
}