Closed talamaska closed 3 months ago
Hey, sorry, I was away for a while and I'm back now. Will check, seems to be a bug
Same here.
I think I have found what's the issue. The problem is that you initially set _data and _resetData and _initialData to something. Then the maybeSetAspectRatioOnInit is called MaterialCroppableImageController, which performs some resize of the crop rectangular to match the aspect ration and then some normalization. At this point _resetData and _initialData are already different. So when reset is called it reassigns the _resetData to data, which is not what the real initial State of the view was. also the reset button is show even in the beginning before doing any transforms for the same reason. After maybeSetAspectRatioOnInit _data is different from _initialData and from _resetData, which is reflected to the ui with recomputeValueNotifiers. So in order to fix this I added in croppable_image_controller
set resetData(CroppableImageData newData) {
if (_resetData == newData) return;
_resetData = newData;
recomputeValueNotifiers();
}
and
set initialData(CroppableImageData newData) {
if (_initialData == newData) return;
_initialData = newData;
recomputeValueNotifiers();
}
and in aspect_ratio_mixin added
resetData = data.copyWith();
initialData = data.copyWith();
In the end of the method maybeSetAspectRatioOnInit just after the normalize call.
I'm not 100% sure this is right, but it's working for the rectangular and ellipse crops. gonna prepare a PR.
Will be deployed in the next release. Feel free to reopen this if this persists
I have been experimenting with the example. I've been wondering how to lock the size of rectangular and force it be always square. I have discovered the allowedAspectRatios. When changing to 1:1 the example correctly opens the cropper with a square cropping area and cannot be resized to some other type of rectangular(not square) by dragging the corners. Which is what I wanted. But after doing some rotations, panning and scaling and clicking Reset, the image is restored to original scale and rotation but the cropping area is changed to a rectangular, which is not a square.