clearGraph method
void
clearGraph()
Clears the entire graph, removing all nodes, connections, annotations, and selections.
This operation:
- Removes all nodes
- Removes all connections
- Clears all selections
- Removes all annotations
- Clears the connection painter cache
Does nothing if the graph is already empty.
Example:
controller.clearGraph();
Implementation
void clearGraph() {
if (_nodes.isEmpty && _connections.isEmpty) return;
runInAction(() {
_nodes.clear();
_connections.clear();
_selectedNodeIds.clear();
_selectedConnectionIds.clear();
annotations.annotations.clear();
annotations.clearAnnotationSelection();
});
// Clear connection painter cache to prevent stale paths
_connectionPainter?.clearAllCachedPaths();
}