Can I add custom data to EditorStateHistory? #513
-
|
I want to extend the EditorStateHistory class to store custom data for my background removal feature. Specifically, I need to save both the original image and the background-removed image in the state history. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
It's not possible to directly extend But you can handle it directly in your code. Simply add an empty history callbacks: ProImageEditorCallbacks(
mainEditorCallbacks: MainEditorCallbacks(
onUndo: () {
editorKey.currentState!.updateBackgroundImage(image);
},
onRedo: () {
editorKey.currentState!.updateBackgroundImage(image);
},
),
), |
Beta Was this translation helpful? Give feedback.
It's not possible to directly extend
EditorStateHistoryunless you fork the entire project.But you can handle it directly in your code. Simply add an empty history
editorKey.currentState!.addHistory(). However, you'll also need to specify in your code at which history index the background changed. To get the active history index, useeditorKey.currentState!.stateManager.historyPointer. The final step is to listen for undo/redo actions and apply the correct background image based on your state.