createGroupAnnotation method

GroupAnnotation createGroupAnnotation({
  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 visually groups multiple nodes.

Group annotations automatically resize to encompass their contained nodes. They appear as colored rectangles behind the nodes with a title.

Parameters:

  • title: Title displayed at the top of the group
  • nodeIds: Set of node IDs to include in the group
  • id: Optional custom ID (auto-generated if not provided)
  • padding: Padding around the grouped nodes (default: 20.0 on all sides)
  • color: Background color of the group (default: blue)

Returns the created GroupAnnotation.

Example:

controller.createGroupAnnotation(
  title: 'Input Processing',
  nodeIds: {'node1', 'node2', 'node3'},
  color: Colors.blue.withOpacity(0.2),
);

Implementation

GroupAnnotation createGroupAnnotation({
  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.createGroupAnnotation(
    id: id ?? 'group-${DateTime.now().millisecondsSinceEpoch}',
    title: title,
    nodeIds: nodeIds,
    nodes: _nodes,
    // Pass the nodes map for initial positioning
    padding: padding,
    color: color,
  );
  addAnnotation(annotation);
  return annotation;
}