findByKey function

FFNode? findByKey(
  1. FFNode root,
  2. String key
)

Finds a node by its unique key via depth-first search.

Searches the entire subtree rooted at root, including root itself. Returns null if no node with the given key exists.

final btn = findByKey(page.node, 'Button_a1b2c3d4');

Implementation

FFNode? findByKey(FFNode root, String key) {
  final path = <FFNode>[];
  if (!_buildPath(root, key, path)) return null;
  return path.last;
}