updateByKey function

bool updateByKey(
  1. FFNode root,
  2. String key,
  3. void mutate(
    1. FFNode
    )
)

Mutates the node with key in-place using mutate.

Unlike replaceByKey, this works on the root node too (no parent needed). Returns false if the key is not found.

updateByKey(root, 'Button_abc', (n) => n.name = 'Submit Order');

Implementation

bool updateByKey(FFNode root, String key, void Function(FFNode) mutate) {
  final node = findByKey(root, key);
  if (node == null) return false;
  mutate(node);
  return true;
}