use api pagination until all the data is fetched in the background

Viewed 326

I have a long list of data coming from database, I'm using pagination and i want to fetch all the list in the background and and view it all instead of viewing page by page.

//first using pagination for faster call
var myLongList =[];
 myLongList = await fetchData(pageSize);

//then show all the data when it's ready
fetchData().then((value) {
myLongList.clear();
setState(() {
  myLongList.addAll(value); 
});


});

is that a good approach to follow? or there is something better i can try I'm doing this to give a better user experience without the waiting for every search or every new data.

1 Answers
Related