paintBackground method
Implementation
Size paintBackground(Canvas canvas, Size size, ui.Image image) {
final imageSize = Size(image.width.toDouble(), image.height.toDouble());
final FittedSizes sizes = applyBoxFit(BoxFit.contain, imageSize, size);
final Rect dstRect =
Alignment.center.inscribe(sizes.destination, Offset.zero & size);
canvas.drawImageRect(image, Offset.zero & imageSize, dstRect, Paint());
return sizes.destination;
}