diff --git a/lib/src/widget/crop.dart b/lib/src/widget/crop.dart index 81e719a..761d766 100644 --- a/lib/src/widget/crop.dart +++ b/lib/src/widget/crop.dart @@ -363,7 +363,7 @@ class _CropEditorState extends State<_CropEditor> { /// apply crop rect changed to view state void _updateCropRect(CropEditorViewState newState) { setState(() => _viewState = newState); - widget.onMoved?.call(_readyState.cropRect, _readyState.imageBaseRect); + widget.onMoved?.call(_readyState.cropRect, _readyState.rectToCrop); } /// reset image to be cropped diff --git a/lib/src/widget/crop_editor_view_state.dart b/lib/src/widget/crop_editor_view_state.dart index eb8691e..ad87b79 100644 --- a/lib/src/widget/crop_editor_view_state.dart +++ b/lib/src/widget/crop_editor_view_state.dart @@ -98,15 +98,8 @@ class ReadyCropEditorViewState extends CropEditorViewState { ); late final rectToCrop = ImageBasedRect.fromLTWH( - (cropRect.left - imageRect.left) * screenSizeRatio / scale, - (cropRect.top - imageRect.top) * screenSizeRatio / scale, - cropRect.width * screenSizeRatio / scale, - cropRect.height * screenSizeRatio / scale, - ); - - late final imageBaseRect = Rect.fromLTWH( - (cropRect.left - imageRect.left) * screenSizeRatio / scale, - (cropRect.top - imageRect.top) * screenSizeRatio / scale, + (max(0, cropRect.left - imageRect.left)) * screenSizeRatio / scale, + (max(0, cropRect.top - imageRect.top)) * screenSizeRatio / scale, cropRect.width * screenSizeRatio / scale, cropRect.height * screenSizeRatio / scale, );