setNodePosition method

void setNodePosition(
  1. String nodeId,
  2. Offset position
)

Sets a node's position to an absolute position.

The position will be automatically snapped to the grid if snap-to-grid is enabled in the controller's configuration.

Example:

controller.setNodePosition('node1', Offset(200, 150));

Implementation

void setNodePosition(String nodeId, Offset position) {
  final node = _nodes[nodeId];
  if (node != null) {
    runInAction(() {
      node.position.value = position;
      node.setVisualPosition(_config.snapToGridIfEnabled(position));
    });
    internalMarkNodeDirty(nodeId);
  }
}