setNodePosition method
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.
Does nothing if the node doesn't exist.
Parameters:
nodeId: The ID of the node to repositionposition: The new absolute position in graph coordinates
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;
// Update visual position with snapping
node.setVisualPosition(_config.snapToGridIfEnabled(position));
});
}
}