Skip to content

Commit

Permalink
fix: respect initial size if specified when changing aspectRatio via …
Browse files Browse the repository at this point in the history
…controller
  • Loading branch information
chooyan-eng committed Dec 11, 2024
1 parent c824703 commit 482d202
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/src/widget/crop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class _CropEditorState extends State<_CropEditor> {
/// detected image format with [widget.formatDetector]
ImageFormat? _detectedFormat;

double? _sizeCache;

@override
void initState() {
super.initState();
Expand All @@ -312,11 +314,11 @@ class _CropEditorState extends State<_CropEditor> {
_cropController.delegate = CropControllerDelegate()
..onCrop = _crop
..onChangeAspectRatio = (aspectRatio) {
_resizeWithSizeAndRatio(null, aspectRatio);
_resizeWithSizeAndRatio(_sizeCache, aspectRatio);
}
..onChangeWithCircleUi = (withCircleUi) {
_viewState = _readyState.copyWith(withCircleUi: withCircleUi);
_resizeWithSizeAndRatio(null, null);
_resizeWithSizeAndRatio(_sizeCache, null);
}
..onImageChanged = _resetImage
..onChangeCropRect = (newCropRect) {
Expand Down Expand Up @@ -473,6 +475,7 @@ class _CropEditorState extends State<_CropEditor> {
_resizeWithArea(builder.area);
case (WithSizeAndRatioInitialRectBuilder()):
_resizeWithSizeAndRatio(builder.size, builder.aspectRatio);
_sizeCache = builder.size;
default:
_resizeWithSizeAndRatio(null, widget.aspectRatio);
}
Expand Down

0 comments on commit 482d202

Please sign in to comment.