isStrictDescendantOf method

bool isStrictDescendantOf(
  1. TKey node,
  2. TKey ancestor
)

Whether node is a strict descendant of ancestor, excluding ancestor itself. An O(depth) ancestor walk that allocates nothing, which matters because drop-target resolution asks it up to three times per pointer move.

Public, unlike the other helpers, because commit-time re-validation in TreeReorderController.endDrag runs the same cycle check.

Implementation

bool isStrictDescendantOf(TKey node, TKey ancestor) {
  TKey? current = treeController.getParent(node);
  while (current != null) {
    if (current == ancestor) {
      return true;
    }
    current = treeController.getParent(current);
  }
  return false;
}