updateNode static method

EditorEdit updateNode(
  1. ElementId id,
  2. Node update(
    1. Node node
    )
)

Implementation

static EditorEdit updateNode(
  rt.ElementId id,
  rt.Node Function(rt.Node node) update,
) {
  return (scene) {
    final node = rt.findById(scene, id);

    if (node == null) {
      return EditorEditResult(scene: scene);
    }

    final nextNode = update(node);

    if (identical(nextNode, node) || nextNode == node) {
      return EditorEditResult(scene: scene, primaryId: id);
    }

    return EditorEditResult(
      scene: rt.replaceById(scene, id, nextNode),
      primaryId: id,
    );
  };
}