nearestDescendantValueKeyLocatorId function

String? nearestDescendantValueKeyLocatorId(
  1. Element element
)

Depth-first: first compact ValueKey under element (not on element).

Used only by observe keep-logic (rare), not by per-step finders.

Implementation

String? nearestDescendantValueKeyLocatorId(Element element) {
  String? found;
  void walk(Element node) {
    if (found != null) return;
    node.visitChildren((child) {
      if (found != null) return;
      final keyId = readValueKeyLocatorId(child);
      if (keyId != null) {
        found = keyId;
        return;
      }
      walk(child);
    });
  }

  walk(element);
  return found;
}