setNodeShapeBuilder method
Sets the node shape builder function.
This function will be called for each node to determine its visual shape.
The builder receives the node and should return a NodeShape or null
for the default rectangular shape.
Example:
controller.setNodeShapeBuilder((node) {
switch (node.type) {
case 'Terminal':
return CircleShape(fillColor: Colors.blue, strokeColor: Colors.black);
case 'Decision':
return DiamondShape(fillColor: Colors.yellow, strokeColor: Colors.black);
default:
return null; // Rectangular node
}
});
Implementation
void setNodeShapeBuilder(NodeShape? Function(Node<T> node)? builder) {
_nodeShapeBuilder = builder;
// Update the connection painter's node shape getter if it exists
// Cast to Node<dynamic> since ConnectionPainter is not generic
_connectionPainter?.updateNodeShape(
builder != null ? (node) => builder(node as Node<T>) : null,
);
}