createCommentNode method
Creates and adds a comment node to the graph.
Comment nodes are floating text elements that can be placed anywhere on the canvas. They support inline editing and auto-grow when text exceeds bounds.
Parameters:
position: Position in graph coordinatestext: The text content of the commentdata: Custom data of typeTassociated with this nodeid: Optional custom ID (auto-generated if not provided)width: Width of the comment (default: 200.0)height: Height of the comment (default: 100.0)color: Background color (default: light yellow)
Returns the created CommentNode.
Example:
controller.createCommentNode(
position: Offset(100, 100),
text: 'Important note here',
data: MyNodeData(),
color: Colors.yellow,
);
Implementation
CommentNode<T> createCommentNode({
required Offset position,
required String text,
required T data,
String? id,
double width = 200.0,
double height = 100.0,
Color color = const Color(0xFFFFF59D), // Light yellow
}) {
final node = CommentNode<T>(
id: id ?? 'comment-${DateTime.now().millisecondsSinceEpoch}',
position: position,
text: text,
data: data,
width: width,
height: height,
color: color,
);
addNode(node);
return node;
}