loadMore method
Loads the next page of data.
Implementation
Future<void> loadMore() async {
if (_isLoading || !_hasMore) return;
_isLoading = true;
_error = null;
notifyListeners();
try {
final result = await onFetch(_currentPage);
_items.addAll(result.items);
_pageItemCounts[_currentPage] = result.items.length;
_hasMore = result.hasMore;
_currentPage++;
} catch (e) {
_error = e;
} finally {
_isLoading = false;
notifyListeners();
}
}