createGroupAnnotationAroundNodes method

GroupAnnotation createGroupAnnotationAroundNodes({
  1. required String title,
  2. required Set<String> nodeIds,
  3. String? id,
  4. EdgeInsets padding = const EdgeInsets.all(20.0),
  5. Color color = const Color(0xFF2196F3),
})

Creates and adds a group annotation that surrounds the specified nodes.

This is a convenience method that calculates the bounding box of the given nodes and creates a group that encompasses them with padding.

Parameters:

  • title: Display title for the group header
  • nodeIds: Set of node IDs to surround
  • id: Optional custom ID (auto-generated if not provided)
  • padding: Space between the group boundary and the nodes (default: 20.0)
  • color: Background color of the group (default: blue)

Returns the created GroupAnnotation.

Example:

controller.createGroupAnnotationAroundNodes(
  title: 'Input Processing',
  nodeIds: {'node1', 'node2', 'node3'},
  padding: EdgeInsets.all(30),
  color: Colors.blue,
);

Implementation

GroupAnnotation createGroupAnnotationAroundNodes({
  required String title,
  required Set<String> nodeIds,
  String? id,
  EdgeInsets padding = const EdgeInsets.all(20.0),
  Color color = const Color(0xFF2196F3), // Blue
}) {
  final annotation = annotations.createGroupAnnotationAroundNodes(
    id: id ?? 'group-${DateTime.now().millisecondsSinceEpoch}',
    title: title,
    nodeIds: nodeIds,
    padding: padding,
    color: color,
  );
  addAnnotation(annotation);
  return annotation;
}