paint method

  1. @override
void paint(
  1. Context context
)
override

Draw itself and its children, according to the calculated box.offset

Implementation

@override
void paint(Context context) {
  super.paint(context);

  final _alignment = Alignment(alignment.x, -alignment.y);
  final sourceRect = _alignment.inscribe(sizes.source!, _svgParser.viewBox);
  final sx = sizes.destination!.x / sizes.source!.x;
  final sy = sizes.destination!.y / sizes.source!.y;
  final dx = sourceRect.left * sx;
  final dy = sourceRect.bottom * sy;

  final mat = Matrix4.identity()
    ..translateByDouble(box!.left - dx, box!.bottom + dy + box!.height, 0, 1)
    ..scaleByDouble(sx, -sy, 1, 1);

  context.canvas.saveContext();
  if (clip) {
    context.canvas
      ..drawBox(box!)
      ..clipPath();
  }
  context.canvas.setTransform(mat);

  final painter = SvgPainter(
    _svgParser,
    context.canvas,
    context.document,
    PdfRect(
      0,
      0,
      context.page.pageFormat.width,
      context.page.pageFormat.height,
    ),
    customFontLookup: customFontLookup,
  );
  painter.paint();
  context.canvas.restoreContext();
}