addressableCandidates method
Returns up to 5 candidate nodes for enricher probing.
Prefers SHALLOW user-code nodes: nodes close to the Scaffold level have
accurate ModalRoute.settings.name. Deep nodes (inside ShellRoute inner
navigators or PageView pages) sit inside nested routes whose settings.name
is null or different from the outer GoRouter path.
within restricts the walk to that subtree (e.g. the active page), so
probes can't land on a covered sibling route.
Implementation
List<SceneNode> addressableCandidates({int max = 5, SceneNode? within}) {
final walkRoot = within ?? root;
final seen = <String>{};
final result = <SceneNode>[];
// First pass: shallow (depth ≤ 12) user-code nodes, skipping platform views.
for (final n in walkRoot.walk().skip(1)) {
if (result.length >= max) break;
if (n.isOffstage || n.inspectorId.isEmpty) continue;
if (n.glintId == null || n.glintId!.isEmpty) continue;
if (n.isPlatformView) continue;
if (n.depth > kShallowProbeMaxDepth) continue;
if (!seen.add(n.inspectorId)) continue;
if (n.createdByLocalProject) result.add(n);
}
// Second pass: any addressable node (deeper fallbacks).
for (final n in walkRoot.walk().skip(1)) {
if (result.length >= max) break;
if (n.isOffstage || n.inspectorId.isEmpty) continue;
if (n.glintId == null || n.glintId!.isEmpty) continue;
if (n.isPlatformView) continue;
if (!seen.add(n.inspectorId)) continue;
result.add(n);
}
return result;
}