buildWidget abstract method

Widget buildWidget(
  1. BuildContext context
)

Builds the visual representation of the annotation.

This method is called by the framework to render the annotation's content. Implement this to define how your custom annotation appears on the canvas.

The framework automatically wraps your widget with:

  • Positioning logic (using visualPosition)
  • Selection visual feedback
  • Theme-consistent borders and highlights

Example

@override
Widget buildWidget(BuildContext context) {
  return Container(
    width: size.width,
    height: size.height,
    decoration: BoxDecoration(
      color: Colors.blue,
      borderRadius: BorderRadius.circular(8),
    ),
    child: Center(child: Text('My Annotation')),
  );
}

Implementation

Widget buildWidget(BuildContext context);