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.x * sx;
  final dy = sourceRect.y * sy;

  final mat = Matrix4.identity()
    ..translate(
      box!.x - dx,
      box!.y + dy + box!.height,
    )
    ..scale(sx, -sy);

  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,
    ),
  );
  painter.paint();
  context.canvas.restoreContext();
}