collectSnapshotSources function

Set<SnapshotSource> collectSnapshotSources(
  1. List<Scene> scenes
)

Gathers every declared SnapshotSource from scenes before the frame loop — the snapshot sibling of collectMediaSources, walking the same tree with no mounting and no async.

Mermaid, WebView, and Html are carriers whose snapshotSource is read straight off the constructor (a computed snapshot, not a loaded media), so the render harness can hand the result to MediaResolver.preResolveSnapshots before frame 0. The result is a Set, so the same diagram or page across scenes rasterizes once (the cache deduplicates by value equality).

Implementation

Set<SnapshotSource> collectSnapshotSources(List<Scene> scenes) {
  final sources = <SnapshotSource>{};
  walkSceneTree(scenes, (widget) {
    if (widget is! MediaCarrier) return;
    final source = (widget as MediaCarrier).snapshotSource;
    if (source != null) sources.add(source);
  });
  return sources;
}