getMore method
If a collection has more items available on the server getMore will call nextPage internally, will extend the current data with the the new data and then will update this collection with new query, meta, and response values.
It returns true
if new items were fetched or false
otherwise
You should not call this function unless you first check hasMore or you expect new resources have been added on the server. Otherwise it might be a wasted request.
while (res.hasMore) {
await res.getMore();
}
// -- your code that saves a new item on the server --
await res.getMore();
Implementation
Future<bool> getMore() async {
var newCollection = await nextPage();
if (newCollection.items.isNotEmpty) {
query = newCollection.query;
meta = newCollection.meta;
response = newCollection.response;
items.addAll(newCollection.items);
return true;
}
return false;
}