layout method
layout API.
Implementation
@override
PwBox layout(Context context, BoxConstraints constraints) {
final _SvgDoc doc = _SvgParser().parse(svg);
final PwSize box = constraints.constrain(PwSize(width, height));
return CustomPaint(
size: box,
painter: (PdfCanvas canvas, PwSize painted) {
canvas.endText();
final SvgViewBox vb = doc.viewBox ??
SvgViewBox(0, 0, painted.width, painted.height);
final double sx = painted.width / vb.width;
final double sy = painted.height / vb.height;
for (final _SvgShape shape in doc.shapes) {
shape.paint(
canvas,
sx: sx,
sy: sy,
ox: -vb.minX * sx,
oy: -vb.minY * sy,
fallbackColor: color,
fallbackStroke: strokeWidth,
);
}
},
).layout(context, constraints);
}