createGroupAnnotation method
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 groupposition: Position in graph coordinatessize: Size of the groupid: 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;
}