File tree Expand file tree Collapse file tree 5 files changed +39
-6
lines changed Expand file tree Collapse file tree 5 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 11.2.1
4
+ - ** FIX** (state-history): Resolve issue where updating the background-image overwrote previous states.
5
+
3
6
## 11.2.0
4
7
- ** FEAT** (state-history): Added support for undo and redo when the background image is changed in the state history.
5
8
Original file line number Diff line number Diff line change @@ -229,6 +229,35 @@ class EditorImage {
229
229
if (list == null ) return 0 ;
230
230
return list.fold (0 , (hash, byte) => hash * 31 + byte);
231
231
}
232
+
233
+ /// Creates a copy of this [EditorImage] with optional new values for its
234
+ /// fields.
235
+ ///
236
+ /// If a parameter is not provided, the current value from this instance
237
+ /// is used.
238
+ /// - [byteArray] : The new image data as a [Uint8List] . If provided, a
239
+ /// copy is created.
240
+ /// - [file] : The new image file as a [File] . If provided, a new [File]
241
+ /// instance is created with the same path.
242
+ /// - [networkUrl] : The new network URL for the image.
243
+ /// - [assetPath] : The new asset path for the image.
244
+ ///
245
+ /// Returns a new [EditorImage] instance with the updated values.
246
+ EditorImage copyWith ({
247
+ Uint8List ? byteArray,
248
+ File ? file,
249
+ String ? networkUrl,
250
+ String ? assetPath,
251
+ }) {
252
+ final bytes = byteArray ?? this .byteArray;
253
+ final fileHelper = file ?? this .file;
254
+ return EditorImage (
255
+ byteArray: bytes != null ? Uint8List .fromList (bytes) : null ,
256
+ file: fileHelper != null ? File (fileHelper.path) : null ,
257
+ networkUrl: networkUrl ?? this .networkUrl,
258
+ assetPath: assetPath ?? this .assetPath,
259
+ );
260
+ }
232
261
}
233
262
234
263
/// Flutter EditorImageType Enum Documentation
Original file line number Diff line number Diff line change @@ -1023,14 +1023,15 @@ class ProImageEditorState extends State<ProImageEditor>
1023
1023
}
1024
1024
stateManager.activeBackgroundImage = image;
1025
1025
} else {
1026
+ addHistory ();
1026
1027
stateManager.updateBackgroundImages (
1027
1028
oldImage: editorImage ?? widget.editorImage! ,
1028
1029
newImage: image,
1029
1030
);
1030
- addHistory ();
1031
1031
}
1032
1032
1033
1033
await decodeImage ();
1034
+ _rebuildController.add (null );
1034
1035
}
1035
1036
1036
1037
@override
Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ class StateManager {
69
69
required EditorImage oldImage,
70
70
required EditorImage newImage,
71
71
}) {
72
- _backgroundImages[historyPointer] = oldImage;
73
- _backgroundImages[historyPointer + 1 ] = newImage;
74
- activeBackgroundImage = newImage;
72
+ _backgroundImages[historyPointer - 1 ] ?? = oldImage. copyWith () ;
73
+ _backgroundImages[historyPointer] = newImage. copyWith () ;
74
+ activeBackgroundImage = newImage. copyWith () ;
75
75
}
76
76
77
77
/// A setter for updating the state history list.
@@ -132,7 +132,7 @@ class StateManager {
132
132
onStateHistoryChange? .call ();
133
133
134
134
if (_backgroundImages[historyPointer] != null ) {
135
- activeBackgroundImage = _backgroundImages[historyPointer];
135
+ activeBackgroundImage = _backgroundImages[historyPointer]! . copyWith () ;
136
136
}
137
137
}
138
138
Original file line number Diff line number Diff line change 1
1
name : pro_image_editor
2
2
description : " A Flutter image editor: Seamlessly enhance your images with user-friendly editing features."
3
- version : 11.2.0
3
+ version : 11.2.1
4
4
homepage : https://github.com/hm21/pro_image_editor/
5
5
repository : https://github.com/hm21/pro_image_editor/
6
6
documentation : https://github.com/hm21/pro_image_editor/
You can’t perform that action at this time.
0 commit comments