toMap method
The scene as a map; fold off = plain toJson. maxDepth drops
children below that many levels (a childCount stands in).
Implementation
Map<String, Object?> toMap(SemanticScene scene, {bool fold = true, int? maxDepth}) {
Map<String, Object?> node(SemanticNode n, int depth) => nodeMap(n, fold: fold, maxDepth: maxDepth, depth: depth);
return {
if (scene.overlayLayers.isNotEmpty)
'overlayLayers': [
for (final l in scene.overlayLayers)
{
'kind': l.kind,
if (l.isBarriered) 'isBarriered': true,
'nodes': [for (final n in l.nodes) node(n, 0)],
}
],
'root': node(scene.root, 0),
if (scene.routeStack.isNotEmpty) 'routeStack': scene.routeStack.map((r) => r.toJson()).toList(),
};
}