Skip to content

Commit cb36967

Browse files
authored
merge: pull request #654 from hm21:dev
fix(main_editor): ensure screenshots are marked as broken when updating background images
2 parents 317d99b + b2ce74d commit cb36967

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 11.5.6
4+
- **FIX**(image-generation): Resolve issue where updating the background image could throw an error when exporting the image. Resolves issue [#652](https://github.com/hm21/pro_image_editor/issues/652).
5+
36
## 11.5.5
47
- **FIX**(video-trim-bar): Resolve issue where `maxDuration` displayed an incorrect time span when its value exceeded the video duration. Resolves issue [#648](https://github.com/hm21/pro_image_editor/issues/648).
58

lib/features/main_editor/main_editor.dart

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,16 +1047,24 @@ class ProImageEditorState extends State<ProImageEditor>
10471047
item.broken = true;
10481048
}
10491049
stateManager.activeBackgroundImage = image;
1050+
1051+
await decodeImage();
1052+
_rebuildController.add(null);
10501053
} else {
10511054
addHistory();
1052-
stateManager.updateBackgroundImages(
1053-
oldImage: editorImage ?? widget.editorImage!,
1054-
newImage: image,
1055-
);
1056-
}
10571055

1058-
await decodeImage();
1059-
_rebuildController.add(null);
1056+
/// Ensure the screenshot is already added to the task list.
1057+
WidgetsBinding.instance.addPostFrameCallback((_) async {
1058+
WidgetsBinding.instance.addPostFrameCallback((_) async {
1059+
stateManager.updateBackgroundImages(
1060+
oldImage: editorImage ?? widget.editorImage!,
1061+
newImage: image,
1062+
);
1063+
await decodeImage();
1064+
_rebuildController.add(null);
1065+
});
1066+
});
1067+
}
10601068
}
10611069

10621070
@override

lib/features/main_editor/services/state_manager.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ class StateManager {
7272
_backgroundImages[historyPointer - 1] ??= oldImage.copyWith();
7373
_backgroundImages[historyPointer] = newImage.copyWith();
7474
activeBackgroundImage = newImage.copyWith();
75+
for (var item in screenshots) {
76+
item.broken = true;
77+
}
7578
}
7679

7780
/// A setter for updating the state history list.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: pro_image_editor
22
description: "A Flutter image editor: Seamlessly enhance your images with user-friendly editing features."
3-
version: 11.5.5
3+
version: 11.5.6
44
homepage: https://github.com/hm21/pro_image_editor/
55
repository: https://github.com/hm21/pro_image_editor/
66
documentation: https://github.com/hm21/pro_image_editor/

0 commit comments

Comments
 (0)