Skip to content

Commit 8a4fd03

Browse files
author
Yan Kochkin
committed
format fix
1 parent 4874810 commit 8a4fd03

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

lib/src/calculators/calculate_crop_params.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ CropFitParams calculateCropParams({
2020
case CustomImageFit.fitCropSpace:
2121
final cropSize = min(screenWidth, screenHeight);
2222
final cropSizeToPaint = cropSize * cropPercentage;
23-
final defaultScale = (cropSize * cropPercentage) / max(imageWidth, imageHeight);
23+
final defaultScale =
24+
(cropSize * cropPercentage) / max(imageWidth, imageHeight);
2425

2526
return CropFitParams(cropSize, cropSizeToPaint, defaultScale);
2627

lib/src/calculators/calculate_on_crop_params.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ OnCropParams caclulateOnCropParams({
5050
if (screenHeight < screenWidth) {
5151
uiSize = screenHeight;
5252
cropSize = imageHeight.toDouble();
53-
translateScale = cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
53+
translateScale =
54+
cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
5455
scale = dataScale / cropPercentage * (screenHeight / screenWidth);
5556
} else {
5657
uiSize = screenWidth;
@@ -69,7 +70,8 @@ OnCropParams caclulateOnCropParams({
6970
if (screenHeight > screenWidth) {
7071
uiSize = screenHeight;
7172
cropSize = imageHeight.toDouble();
72-
translateScale = cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
73+
translateScale =
74+
cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
7375
scale = dataScale / cropPercentage * (screenHeight / screenWidth);
7476
} else {
7577
uiSize = screenWidth;
@@ -82,7 +84,8 @@ OnCropParams caclulateOnCropParams({
8284
case CustomImageFit.fillVisibleHeight:
8385
final uiSize = screenHeight;
8486
final cropSize = imageHeight.toDouble();
85-
final translateScale = cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
87+
final translateScale =
88+
cropSize / uiSize / cropPercentage * (screenHeight / screenWidth);
8689
final scale = dataScale / cropPercentage * (screenHeight / screenWidth);
8790

8891
return OnCropParams(cropSize, translateScale, scale);

lib/src/widgets/custom_image_crop_widget.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,25 +282,28 @@ class _CustomImageCropState extends State<CustomImageCrop>
282282
final pictureRecorder = ui.PictureRecorder();
283283
final canvas = Canvas(pictureRecorder);
284284
final onCropParams = caclulateOnCropParams(
285-
cropPercentage: widget.cropPercentage,
286-
imageFit: widget.imageFit,
287-
imageHeight: imageHeight,
288-
imageWidth: imageWidth,
289-
screenHeight: _height,
290-
screenWidth: _width,
291-
dataScale: data.scale,
285+
cropPercentage: widget.cropPercentage,
286+
imageFit: widget.imageFit,
287+
imageHeight: imageHeight,
288+
imageWidth: imageWidth,
289+
screenHeight: _height,
290+
screenWidth: _width,
291+
dataScale: data.scale,
292292
);
293-
final clipPath =
294-
Path.from(_getPath(onCropParams.cropSize, onCropParams.cropSize, onCropParams.cropSize));
293+
final clipPath = Path.from(_getPath(
294+
onCropParams.cropSize, onCropParams.cropSize, onCropParams.cropSize));
295295
final matrix4Image = Matrix4.diagonal3(vector_math.Vector3.all(1))
296-
..translate(onCropParams.translateScale * data.x + onCropParams.cropSize / 2,
296+
..translate(
297+
onCropParams.translateScale * data.x + onCropParams.cropSize / 2,
297298
onCropParams.translateScale * data.y + onCropParams.cropSize / 2)
298299
..scale(onCropParams.scale)
299300
..rotateZ(data.angle);
300301
final bgPaint = Paint()
301302
..color = widget.backgroundColor
302303
..style = PaintingStyle.fill;
303-
canvas.drawRect(Rect.fromLTWH(0, 0, onCropParams.cropSize, onCropParams.cropSize), bgPaint);
304+
canvas.drawRect(
305+
Rect.fromLTWH(0, 0, onCropParams.cropSize, onCropParams.cropSize),
306+
bgPaint);
304307
canvas.save();
305308
canvas.clipPath(clipPath);
306309
canvas.transform(matrix4Image.storage);
@@ -314,8 +317,8 @@ class _CustomImageCropState extends State<CustomImageCrop>
314317
// final bytes = await compute(computeToByteData, <String, dynamic>{'pictureRecorder': pictureRecorder, 'cropWidth': cropWidth});
315318

316319
ui.Picture picture = pictureRecorder.endRecording();
317-
ui.Image image =
318-
await picture.toImage(onCropParams.cropSize.floor(), onCropParams.cropSize.floor());
320+
ui.Image image = await picture.toImage(
321+
onCropParams.cropSize.floor(), onCropParams.cropSize.floor());
319322

320323
// Adding compute would be preferrable. Unfortunately we cannot pass an ui image to this.
321324
// A workaround would be to save the image and load it inside of the isolate

0 commit comments

Comments
 (0)