Skip to content

Undo and Redo

Content editing supports Undo and Redo, allowing users to quickly revert or restore actions during editing.

Toolbar Actions

Users can directly tap the Undo/Redo buttons on the bottom toolbar.

API Calls

Developers can also use historyManager to implement custom logic:

Set Callback

dart
// Set a listener to track history changes
controller.editManager.historyManager.setOnHistoryChangedListener(
  (pageIndex, canUndo, canRedo) {
    debugPrint(
      'History changed: page=$pageIndex, canUndo=$canUndo, canRedo=$canRedo',
    );
  },
);

// Undo
if (await controller.editManager.historyManager.canUndo()) {
  await controller.editManager.historyManager.undo();
}

// Redo
if (await controller.editManager.historyManager.canRedo()) {
  await controller.editManager.historyManager.redo();
}