resize method
Implementation
SizeAspectRatio resize(
int maxWidth,
int maxHeight,
) {
double scaleFactor = (maxWidth / width > maxHeight / height)
? maxHeight / height
: maxWidth / width;
int newWidth = (width * scaleFactor).round();
int newHeight = (height * scaleFactor).round();
int finalWidth = newWidth.clamp(0, maxWidth);
int finalHeight = newHeight.clamp(0, maxHeight);
return SizeAspectRatio(
width: finalWidth,
height: finalHeight,
);
}