Skip to content

Commit

Permalink
fix: InvalidRectError (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng authored Dec 11, 2024
1 parent 5139639 commit e651777
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/src/widget/crop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions lib/src/widget/crop_editor_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down

0 comments on commit e651777

Please sign in to comment.