From b37d1346a5d5d3ae3de5041fe3f38dcb46baf35f Mon Sep 17 00:00:00 2001 From: "1148648777@qq.com" <1148648777@qq.com> Date: Tue, 25 Apr 2023 21:13:56 +0800 Subject: [PATCH] fix: Resolve issue with CropAspectRatios.original having full height and zero width. --- lib/src/editor/editor.dart | 11 +++++++++-- lib/src/editor/editor_utils.dart | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/src/editor/editor.dart b/lib/src/editor/editor.dart index 6c6b63cf..b8203caf 100644 --- a/lib/src/editor/editor.dart +++ b/lib/src/editor/editor.dart @@ -64,12 +64,19 @@ class ExtendedImageEditorState extends State { widget.extendedImageState.extendedImageInfo!.image.height; } _editActionDetails!.cropAspectRatio = _editorConfig!.cropAspectRatio; + _editActionDetails!.initialCropAspectRatio = + _editorConfig!.initialCropAspectRatio; if (_editorConfig!.cropAspectRatio != null && _editorConfig!.cropAspectRatio! <= 0) { _editActionDetails!.cropAspectRatio = _editActionDetails!.originalAspectRatio; } + if (_editorConfig!.initialCropAspectRatio != null && + _editorConfig!.initialCropAspectRatio! <= 0) { + _editActionDetails!.initialCropAspectRatio = + _editActionDetails!.originalAspectRatio; + } } @override @@ -197,10 +204,10 @@ class ExtendedImageEditorState extends State { _editActionDetails!.cropAspectRatio!, ); } - if (_editorConfig!.initialCropAspectRatio != null) { + if (_editActionDetails!.initialCropAspectRatio != null) { return _calculateCropRectFromAspectRatio( rect, - _editorConfig!.initialCropAspectRatio!, + _editActionDetails!.initialCropAspectRatio!, ); } return _editActionDetails!.getRectWithScale(rect); diff --git a/lib/src/editor/editor_utils.dart b/lib/src/editor/editor_utils.dart index bd4116b3..9aee74ec 100644 --- a/lib/src/editor/editor_utils.dart +++ b/lib/src/editor/editor_utils.dart @@ -41,6 +41,8 @@ class EditActionDetails { _cropAspectRatio = value; } + double? initialCropAspectRatio; + ///image Rect? get screenDestinationRect => _screenDestinationRect;