@@ -18,37 +18,35 @@ CropFitParams calculateCropParams({
18
18
19
19
switch (imageFit) {
20
20
case CustomImageFit .fitCropSpace:
21
- final cropSize = min (screenWidth, screenHeight);
22
- final cropSizeToPaint = cropSize * cropPercentage;
23
- final defaultScale =
24
- (cropSize * cropPercentage) / max (imageWidth, imageHeight);
21
+ final cropSize = min (screenWidth, screenHeight) * cropPercentage;
22
+ final cropSizeToPaint = cropSize;
23
+ final defaultScale = cropSize / max (imageWidth, imageHeight);
25
24
26
25
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
27
26
28
27
case CustomImageFit .fillCropWidth:
29
- final cropSize = screenWidth;
30
- final cropSizeToPaint = cropSize * cropPercentage ;
31
- final defaultScale = ( cropSize * cropPercentage) / imageWidth;
28
+ final cropSize = screenWidth * cropPercentage ;
29
+ final cropSizeToPaint = cropSize;
30
+ final defaultScale = cropSize / imageWidth;
32
31
33
32
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
34
33
case CustomImageFit .fillCropHeight:
35
- final cropSize = screenHeight;
36
- final cropSizeToPaint = cropSize * cropPercentage ;
37
- final defaultScale = ( cropSize * cropPercentage) / imageHeight;
34
+ final cropSize = screenHeight * cropPercentage ;
35
+ final cropSizeToPaint = cropSize;
36
+ final defaultScale = cropSize / imageHeight;
38
37
39
38
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
40
39
case CustomImageFit .fitVisibleSpace:
41
40
late final double cropSize;
42
41
late final double cropSizeToPaint;
43
42
late final double defaultScale;
43
+ cropSizeToPaint = min (screenWidth, screenHeight) * cropPercentage;
44
44
45
45
if (screenHeight < screenWidth) {
46
46
cropSize = screenHeight;
47
- cropSizeToPaint = screenWidth * cropPercentage;
48
47
defaultScale = screenHeight / imageHeight;
49
48
} else {
50
49
cropSize = screenWidth;
51
- cropSizeToPaint = cropSize * cropPercentage;
52
50
defaultScale = screenWidth / imageWidth;
53
51
}
54
52
@@ -57,27 +55,26 @@ CropFitParams calculateCropParams({
57
55
late final double cropSize;
58
56
late final double cropSizeToPaint;
59
57
late final double defaultScale;
58
+ cropSizeToPaint = min (screenWidth, screenHeight) * cropPercentage;
60
59
61
60
if (screenHeight > screenWidth) {
62
61
cropSize = screenHeight;
63
- cropSizeToPaint = screenWidth * cropPercentage;
64
62
defaultScale = screenHeight / imageHeight;
65
63
} else {
66
64
cropSize = screenWidth;
67
- cropSizeToPaint = cropSize * cropPercentage;
68
65
defaultScale = screenWidth / imageWidth;
69
66
}
70
67
71
68
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
72
69
case CustomImageFit .fillVisibleHeight:
73
70
final cropSize = screenHeight;
74
- final cropSizeToPaint = screenWidth * cropPercentage;
71
+ final cropSizeToPaint = min ( screenWidth, screenHeight) * cropPercentage;
75
72
final defaultScale = screenHeight / imageHeight;
76
73
77
74
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
78
75
case CustomImageFit .fillVisiblelWidth:
79
76
final cropSize = screenWidth;
80
- final cropSizeToPaint = cropSize * cropPercentage;
77
+ final cropSizeToPaint = min (screenWidth, screenHeight) * cropPercentage;
81
78
final defaultScale = screenWidth / imageWidth;
82
79
83
80
return CropFitParams (cropSize, cropSizeToPaint, defaultScale);
0 commit comments