Currently I'am learning lazyloading flutter, i have some errors when load _lazlLoadingLoadMore() after endOfPage Lazyloading is triggered. the original List also removed just like templist.
...
list<ModelData> dataList = value.data.length;
...
Future _lazlLoadingLoadMore() async {
setState(() {
_loading = true;
});
increment = increment 1;
if (increment >= widget.value.data.length) {
increment = widget.value.data.length;
}
tempList = dataList;
tempList.removeRange(increment, dataList.length);
setState(() {
_loading = false;
});}
CodePudding user response:
you can clear temp list and use addAll/assignAll example
List<String> list = [];
List<String> listAll = [];
list.clear();// or list = [];
list.addAll(listAll);// or list.assignAll(listAll);
then call removeRange
list.removeRange(increment, listAll.length);
CodePudding user response:
You can create new instance like
tempList = dataList.toList();//this
tempList.removeRange(increment, dataList.length);