findNode function

FNode? findNode(
  1. FNode root,
  2. bool test(
    1. FNode
    )
)

Correct version of findRecursive: traverses ALL node types, including Root, FluentList, FluentTable and ListItem with sublists.

Replaces the old findRecursive in editor_utils.dart that skipped FluentList and FluentTable.

Implementation

FNode? findNode(FNode root, bool Function(FNode) test) {
  if (test(root)) return root;
  for (final child in childrenOf(root)) {
    final found = findNode(child, test);
    if (found != null) return found;
  }
  return null;
}