createStickyNote method
Creates and adds a sticky note annotation to the graph.
Sticky notes are floating text annotations that can be placed anywhere on the canvas.
Parameters:
position: Position in graph coordinatestext: The text content of the sticky noteid: Optional custom ID (auto-generated if not provided)width: Width of the sticky note (default: 200.0)height: Height of the sticky note (default: 100.0)color: Background color (default: light yellow)offset: Optional offset for positioning (default: Offset.zero)
Returns the created StickyAnnotation.
Example:
controller.createStickyNote(
position: Offset(100, 100),
text: 'Important note here',
color: Colors.yellow,
);
Implementation
StickyAnnotation createStickyNote({
required Offset position,
required String text,
String? id,
double width = 200.0,
double height = 100.0,
Color color = const Color(0xFFFFF59D), // Light yellow
Offset offset = Offset.zero,
}) {
final annotation = annotations.createStickyAnnotation(
id: id ?? 'sticky-${DateTime.now().millisecondsSinceEpoch}',
position: position,
text: text,
width: width,
height: height,
color: color,
offset: offset,
);
addAnnotation(annotation);
return annotation;
}