addLabel method

  1. @override
void addLabel(
  1. String text,
  2. double x,
  3. double y,
  4. Color color, {
  5. double? fontSize,
})
override

Adds a label to be rendered on top of the scene. Coordinates are in transformed screen space (pixels) where origin is the center of canvas.

Implementation

@override
void addLabel(String text, double x, double y, Color color,
    {double? fontSize}) {
  // transform coordinates: painter uses center as origin, TextPainter expects
  // origin at top-left. We keep coordinates in center-origin space and
  // convert when painting.
  _labels.add(_LabelEntry(text, x, y, color, fontSize ?? 12.0));
}