Updates the previous
list using the change records
. For added items,
the current
list is used to find the current value.
static void applyChangeRecords(List<Object> previous, List<Object> current,
List<ListChangeRecord> changeRecords) {
if (identical(previous, current)) {
throw new ArgumentError("can't use same list for previous and current");
}
for (var change in changeRecords) {
int addEnd = change.index + change.addedCount;
int removeEnd = change.index + change.removed.length;
var addedItems = current.getRange(change.index, addEnd);
previous.replaceRange(change.index, removeEnd, addedItems);
}
}