calculateScale method

double calculateScale(
  1. Size? containerSize
)

Implementation

double calculateScale(Size? containerSize) {
  if (containerSize == null) {
    return 1.0;
  }

  // Aspect Ratio
  double newWidth = containerSize.width, newHeight = containerSize.height;
  if (containerSize.width > containerSize.height) {
    newHeight = 1 / (mapSize.aspectRatio / containerSize.width);
  } else {
    newHeight = containerSize.width / mapSize.aspectRatio;
  }
  containerSize = Size(newWidth, newHeight);

  // Scale for Responsive UI
  double scale1 = containerSize.width / mapSize.width;
  double scale2 = containerSize.height / mapSize.height;
  double mapScale = scale1 > scale2 ? scale1 : scale2;

  return mapScale;
}