replaceByKey function

bool replaceByKey(
  1. FFNode root,
  2. String key,
  3. FFNode replacement
)

Replaces the node with key with replacement.

Returns false if key matches the root node or is not found.

replaceByKey(root, 'Text_old', UI.text('New'));

Implementation

bool replaceByKey(FFNode root, String key, FFNode replacement) {
  final result = findParentByKey(root, key);
  if (result == null) return false;
  replaceChild(result.parent, result.child, replacement);
  return true;
}