updateNodeProperties method
- String nodeId,
- ElectricalNode updateFn()
Updates a node's properties ensuring immutability
Implementation
Future<void> updateNodeProperties(
String nodeId, ElectricalNode Function(ElectricalNode) updateFn) async {
final root = state.root;
if (root == null) return;
_saveToHistory();
try {
final newRoot = await _updateNodeUseCase(
params: UpdateNodeParams(root, nodeId, updateFn));
emit(state.copyWith(
root: newRoot,
status: DiagramStatus.ready,
canUndo: true,
canRedo: false));
// Re-validate immediately
await validateDiagram();
} catch (e) {
emit(state.copyWith(errorMessage: "Failed to update node: $e"));
}
}