instantiateScene function

SceneDocument instantiateScene(
  1. SceneDocument template,
  2. Map<String, Object?> args
)

A fresh copy of template with args applied to its parameters — what a SceneRefNode.instance is. The copy keeps the template's parameter declarations and bindings, so it can take new args later.

Implementation

SceneDocument instantiateScene(
  SceneDocument template,
  Map<String, Object?> args,
) {
  var doc = SceneDocument(deepCopyNode(template.root) as FrameNode)
    ..params.addAll(template.params)
    ..tokens.addAll(template.tokens)
    ..tokensFormal = template.tokensFormal;
  doc.applyArgs(args);
  return doc;
}