createMarker method

MarkerAnnotation createMarker({
  1. required Offset position,
  2. MarkerType markerType = MarkerType.info,
  3. String? id,
  4. double size = 24.0,
  5. Color color = const Color(0xFFF44336),
  6. String? tooltip,
  7. Offset offset = Offset.zero,
})

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 coordinates
  • markerType: 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 hover
  • offset: 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;
}