Open Peng-Qian opened 11 hours ago
This is quite critical since we cannot customize the editor and cannot fetch the crop's information.
as design , you should update state by controller
you should update only Text(info) state
I believe the widget should not reset its state when the parent calls setState, as this design significantly limits user customization and its compatibility with other widgets. Requiring an isolated environment for the widget to function makes it inconvenient and less practical for broader use.
Is there a specific reason why this widget needs to unnecessarily reset its state?
Just checked, and version 9.06 works fine with it. It seems there might be a minor bug introduced in the 9.07 update.
I quickly checked the commits, and this issue might be caused by the equality check in lib/src/editor/editor_config.dart:
@Override
int get hashCode {
return Object.hash(
maxScale,
cropRectPadding,
cornerSize,
cornerColor,
lineColor,
lineHeight,
editorMaskColorHandler,
hitTestSize,
animationDuration,
tickerDuration,
cropAspectRatio,
initialCropAspectRatio,
initCropRectType,
cropLayerPainter,
speed,
hitTestBehavior,
editActionDetailsIsChanged,
reverseMousePointerScrollDirection,
controller,
);
}
The issue seems to be introduced in lib/src/editor/editor.dart:
if (oldConfig == config) {
return;
}
_editorConfig = config;
Since the object is immutable, it always fails value equality checks, which forces the widget to reset everything.
I haven’t tested the code yet—this conclusion is based on a quick review of the commits. @zmtzawqlp
@override
void didUpdateWidget(ExtendedImageEditor oldWidget) {
_editActionDetails = null;
_initGestureConfig();
super.didUpdateWidget(oldWidget);
}
reset state when didUpdateWidget. make sure the state is clearing
Version
^9.0.7
Platforms
Android, iOS
Device Model
emulator, iPhone 15 Pro Plus
flutter info
How to reproduce?
dart editActionDetailsIsChanged
part and the crop will not work at all since the bugLogs
No response
Example code (optional)
Contact
No response