tapTargetFor function
The id a tap on node should use: its nearest tappable ancestor-or-self, else its own id.
Implementation
String? tapTargetFor(Iterable<SceneNode> roots, SceneNode node) {
String? found;
bool visit(SceneNode n, String? tappable) {
final here = n.glintId != null && _tappable(n.baseLabel) ? n.glintId : tappable;
if (identical(n, node)) {
found = here ?? n.glintId;
return true;
}
return n.children.any((c) => visit(c, here));
}
roots.any((r) => visit(r, null));
return found;
}