createMarker method
Creates and adds a marker annotation to the graph.
Markers are small icons that can be used to highlight specific locations or draw attention to important points.
Parameters:
position: Position in graph coordinatesmarkerType: Type of marker (info, warning, error, success, etc.)id: Optional custom ID (auto-generated if not provided)size: Size of the marker icon (default: 24.0)color: Color of the marker (default: red)tooltip: Optional tooltip text shown on hoveroffset: Optional offset for positioning (default: Offset.zero)
Returns the created MarkerAnnotation.
Example:
controller.createMarker(
position: Offset(200, 150),
markerType: MarkerType.warning,
tooltip: 'Check this connection',
color: Colors.orange,
);
Implementation
MarkerAnnotation createMarker({
required Offset position,
MarkerType markerType = MarkerType.info,
String? id,
double size = 24.0,
Color color = const Color(0xFFF44336), // Red
String? tooltip,
Offset offset = Offset.zero,
}) {
final annotation = annotations.createMarkerAnnotation(
id: id ?? 'marker-${DateTime.now().millisecondsSinceEpoch}',
position: position,
markerType: markerType,
size: size,
color: color,
tooltip: tooltip,
offset: offset,
);
addAnnotation(annotation);
return annotation;
}