getSizeScale function

Size getSizeScale(
  1. dynamic degrees,
  2. dynamic width,
  3. dynamic height,
  4. dynamic screenWidth,
  5. dynamic screenHeight,
)

Implementation

Size getSizeScale(degrees, width, height, screenWidth, screenHeight){
  double targetWidth = degrees == 0 || degrees == 180 ? screenWidth : screenHeight;
  double targetHeight = degrees == 90 || degrees == 270 ? screenHeight : screenWidth;

  double scaleWidth = targetWidth / width;
  double scaleHeight = targetHeight / height;

  double scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight;

  double resizedWidth = width * scale;
  double resizedHeight = height * scale;

  return Size(resizedWidth, resizedHeight);
}