clearBeyondTopPage method
Clears the database from page 2.
Use-case: we have data on several pages, and the user wants to launch the search again. That means
- all cached results are deprecated
- we start again a search from top page
- we should clear ALL pages
- but we clear only from page 2 and if the search didn't crash (server ko)
- in order to play it safe - when it crashes we still have data
Implementation
Future<void> clearBeyondTopPage() async {
final DaoProductList daoProductList = DaoProductList(localDatabase);
productQuery.toTopPage();
do {
productQuery.toNextPage();
} while (await daoProductList.delete(productQuery.getProductList()));
productQuery.toTopPage();
}