dispatchNewList method
- T newList
Replaces the current list with the new one. Differences are calculated and then dispatched to the coontroller.
Implementation
void dispatchNewList(final T newList) async {
_processingList = newList;
var dr = await _computeDiffs(_currentList, newList);
if (dr == null || newList != _processingList || _processingList == null) {
return; // discard result
}
_oldList = _currentList;
_currentList = _processingList;
_processingList = null;
final oldList = _oldList;
dr.dispatchUpdatesTo(
onInsert: (position, count) {
animatedListController.notifyInsertedRange(position, count);
},
onChange: (position, count) {
animatedListController.notifyChangedRange(position, count,
(context, index) {
return itemBuilder.call(context, oldList, position + index, true);
});
},
onRemove: (position, count) {
animatedListController.notifyRemovedRange(position, count,
(context, index) {
return itemBuilder.call(context, oldList, position + index, true);
});
},
onReplace: (position, removeCount, insertCount) {
animatedListController.notifyReplacedRange(
position, removeCount, insertCount, (context, index) {
return itemBuilder.call(context, oldList, position + index, true);
});
},
);
animatedListController.dispatchChanges();
}