createGroupAnnotation method

GroupAnnotation createGroupAnnotation({
  1. required String title,
  2. required Offset position,
  3. required Size size,
  4. String? id,
  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
  • position: Position in graph coordinates
  • size: Size of the group
  • id: Optional custom ID (auto-generated if not provided)
  • color: Background color of the group (default: blue)

Returns the created GroupAnnotation.

Example:

controller.createGroupAnnotation(
  title: 'Input Processing',
  position: Offset(100, 100),
  size: Size(400, 300),
  color: Colors.blue,
);

Implementation

GroupAnnotation createGroupAnnotation({
  required String title,
  required Offset position,
  required Size size,
  String? id,
  Color color = const Color(0xFF2196F3), // Blue
}) {
  final annotation = annotations.createGroupAnnotation(
    id: id ?? 'group-${DateTime.now().millisecondsSinceEpoch}',
    title: title,
    position: position,
    size: size,
    color: color,
  );
  addAnnotation(annotation);
  return annotation;
}