transitiveSupertypeNames static method
Walk the registered supertype chain (transitively) starting from
className and return the full set of ancestor class names in
breadth-first order. Used by interface-proxy resolution so an
interpreted class like PanelTheme extends InheritedTheme can still
match a proxy factory registered for InheritedWidget up the chain.
Excludes className itself.
Nearest-first, so callers that want the most specific supertype can take
the first match. The seen set is what makes the walk safe on a cyclic
registry — nothing stops a caller registering one.
The result is unmodifiable: it is shared with every other caller through
_transitiveCache, so mutating it would corrupt the next query.
Implementation
static List<String> transitiveSupertypeNames(String className) {
final cached = _transitiveCache[className];
if (cached != null) return cached;
final seen = <String>{};
final order = <String>[];
final queue = <String>[];
final direct = _supertypeRegistry[className];
if (direct != null) queue.addAll(direct);
while (queue.isNotEmpty) {
final next = queue.removeAt(0);
if (!seen.add(next)) continue;
order.add(next);
final step = _supertypeRegistry[next];
if (step != null) queue.addAll(step);
}
final result = List<String>.unmodifiable(order);
_transitiveCache[className] = result;
return result;
}