painterDelegate property

PainterDelegate painterDelegate
final

Controls how the text will be rendered.

By default, it just calls

painter.paint(canvas, size);

You can use this parameter, for example, to add decoration before or after text is drawn. Consider the following delegate to draw background behind the text:

final decorationPaint = Paint()
  ..style = PaintingStyle.stroke
  ..strokeCap = StrokeCap.round
  ..strokeWidth = 32
  ..color = Colors.yellow;

void painterDelegate(Canvas canvas, Size size, ArcTextPainter painter) {
  final rect = Rect.fromCircle(
    center: Offset(size.width / 2, size.height / 2),
    radius: painter.radius,
  );
  canvas.drawArc(
    rect,
    painter.startAngle,
    painter.sweepAngle,
    false,
    decorationPaint,
  );
  painter.paint(canvas, size);
}

For a more complex use case, take a look at the example package.

Don't forget to call painter.paint(canvas, size) in your custom delegate to draw the text itself.

Implementation

final PainterDelegate painterDelegate;