record method
Implementation
void record(Delta change, Delta before) {
if (change.isEmpty) return;
stack.redo.clear();
var undoDelta = change.invert(before);
final timeStamp = DateTime.now().millisecondsSinceEpoch;
if (lastRecorded + interval > timeStamp && stack.undo.isNotEmpty) {
final lastDelta = stack.undo.removeLast();
undoDelta = undoDelta.compose(lastDelta);
} else {
lastRecorded = timeStamp;
}
if (undoDelta.isEmpty) return;
stack.undo.add(undoDelta);
if (stack.undo.length > maxStack) {
stack.undo.removeAt(0);
}
}