chooyan-eng / crop_your_image

A flutter plugin which provides Crop Widget for cropping images.
https://pub.dev/packages/crop_your_image
Apache License 2.0
152 stars 136 forks source link

Instance of 'InvalidRectError' #161

Open yuqing374 opened 3 weeks ago

yuqing374 commented 3 weeks ago

flutter: Instance of 'InvalidRectError' flutter:

0 ImageImageCropper.call (package:crop_your_image/src/logic/cropper/image_image_cropper.dart:35:7)

1 _cropFunc (package:crop_your_image/src/widget/crop.dart:765:18)

2 compute. (package:flutter/src/foundation/_isolates_io.dart:19:20)

3 _RemoteRunner._run (dart:isolate:1090:47)

4 _RemoteRunner._remoteExecute (dart:isolate:1084:12)

5 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:300:17)

6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

version 1.1.0

VitKalini commented 3 weeks ago

@yuqing374 adding initial builder worked for me:

 initialRectBuilder: (viewportRect, imageRect) {
                                final double halfWidth = imageRect.width / 2;
                                final double halfHeight = imageRect.height / 2;

                                return Rect.fromLTWH(
                                    imageRect.left + (imageRect.width - halfWidth) / 2,
                                    imageRect.top + (imageRect.height - halfHeight) / 2,
                                    halfWidth,
                                    halfHeight);
                              },
cjlapao commented 2 weeks ago

the solution from @VitKalini worked for me too