paint method
Draw itself and its children, according to the calculated
box.offset
Implementation
@override
void paint(Context context) {
super.paint(context);
if (child != null) {
final resolvedAlignment = alignment.resolve(Directionality.of(context));
final childSize = child!.box!.size;
final sizes = applyBoxFit(fit, childSize, box!.size);
final scaleX = sizes.destination!.x / sizes.source!.x;
final scaleY = sizes.destination!.y / sizes.source!.y;
final sourceRect = resolvedAlignment.inscribe(
sizes.source!,
PdfRect.fromPoints(PdfPoint.zero, childSize),
);
final destinationRect = resolvedAlignment.inscribe(
sizes.destination!,
box!,
);
final mat =
Matrix4.translationValues(
destinationRect.left,
destinationRect.bottom,
0,
)
..scaleByDouble(scaleX, scaleY, 1, 1)
..translateByDouble(-sourceRect.left, -sourceRect.bottom, 0, 1);
context.canvas
..saveContext()
..drawBox(box!)
..clipPath()
..setTransform(mat);
child!.paint(context);
context.canvas.restoreContext();
}
}