clear method
Clear the controller state.
It creates a new empty ParchmentDocument and a clean edit history.
The old document will be closed if closeDocument is true.
Calling this will notify all the listeners of this FleatherController that they need to update (it calls notifyListeners). For this reason, this method should only be called between frames, e.g. in response to user actions, not during the build, layout, or paint phases.
Implementation
void clear({bool closeDocument = true}) {
_throttleTimer?.cancel();
_toggledStyles = ParchmentStyle();
_selection = const TextSelection.collapsed(offset: 0);
_autoFormats.cancelActive();
if (closeDocument) {
document.close();
}
_document = ParchmentDocument();
_history = HistoryStack.doc(document);
_throttledPush = _throttle(
duration: throttleDuration,
function: _history.push,
);
notifyListeners();
}