update method
Implementation
void update(LinkedList<VNodeEntry> oldList, LinkedList<VNodeEntry> newList) {
if (oldList.isEmpty && newList.isEmpty) {
return;
}
var oldListHasKeys = false;
var oldEntry = oldList.isEmpty ? null : oldList.first;
while (oldEntry != null) {
final vNode = oldEntry.vNode;
if (vNode.key != null) {
oldListHasKeys = true;
break;
}
oldEntry = oldEntry.next;
}
if (oldListHasKeys) {
var newListHasKeys = false;
var newEntry = newList.isEmpty ? null : newList.first;
while (newEntry != null) {
final vNode = newEntry.vNode;
if (vNode.key != null) {
newListHasKeys = true;
break;
}
newEntry = newEntry.next;
}
if (newListHasKeys) {
final diff = Diff();
final patches =
diff.diff(oldList, newList, getKey: _getKey, isEqual: _isEqual);
_removed = {};
_patch(patches, oldList);
if (_removed.isNotEmpty) {
for (final element in _removed) {
element.dispose();
}
_removed = const {};
}
return;
}
}
_updateWithoutKeys(oldList, newList);
}