removeNode method
- String nodeId
Removes a node by ID and validates diagram
Implementation
void removeNode(String nodeId) {
final root = state.root;
if (root == null) return;
if (root.id == nodeId) {
// Cannot remove root directly this way without resetting project
return;
}
_saveToHistory();
final newRoot = TreeUtilities.removeNodeFromTree(root, nodeId);
// Also remove from positions map to cleanup
final newPositions = Map<String, Offset>.from(state.nodePositions)
..remove(nodeId);
if (newRoot != null) {
emit(state.copyWith(
root: newRoot,
nodePositions: newPositions,
status: DiagramStatus.ready,
canUndo: true,
canRedo: false,
));
validateDiagram();
}
}