setImageRatio static method
Implementation
static void setImageRatio(
ImageRatio? imageRatio, CropAspectRatio? aspectRatio) {
if (imageRatio != null) {
switch (imageRatio) {
case ImageRatio.RATIO_1_2:
currentRatioWidth = 1;
currentRatioHeight = 2;
break;
case ImageRatio.RATIO_3_2:
currentRatioWidth = 3;
currentRatioHeight = 2;
break;
case ImageRatio.RATIO_4_3:
currentRatioWidth = 4;
currentRatioHeight = 3;
break;
case ImageRatio.RATIO_16_9:
currentRatioWidth = 16;
currentRatioHeight = 9;
break;
default:
currentRatioWidth = 1;
currentRatioHeight = 1;
}
} else {
if (aspectRatio!.ratioX == 0 && aspectRatio.ratioY == 0) {
currentRatioWidth = 1;
currentRatioHeight = 1;
} else {
currentRatioWidth = aspectRatio.ratioX.toDouble();
currentRatioHeight = aspectRatio.ratioY.toDouble();
}
}
cropSizeWidth = defaultCropSize;
cropSizeHeight = (defaultCropSize * currentRatioHeight) / currentRatioWidth;
if (imageRatio != null)
selectedImageRatio = CropAspectRatio.fromRation(imageRatio);
else {
selectedImageRatio = aspectRatio ?? CropAspectRatio.free();
}
setDefaultButtonPosition();
}