refresh method
Refreshes the data by reloading it from a clean first-page state.
This is a hard refresh: currently loaded pages, cursors, and errors are cleared immediately and the status becomes PageableStatus.LOADING_FIRST_PAGE, so the UI renders its normal first-load experience. The first page is then fetched and applied exactly like an initial load.
Use refreshSilently when existing items should stay visible while the first page is re-fetched.
Implementation
Future<void> refresh() async {
if (useSafeMode && !mounted) return;
trackOperation('refresh');
debugAssertNotDisposed();
// Cancel pending work and invalidate any in-flight results.
_debounceTimer?.cancel();
_fetchingPages.clear();
_requestId += 1;
_log('Refreshing data from a clean first-page state');
value = PageableView.initial(showLog: value.showLog, pageSize: value.pageSize);
// Let any invalidated fetch unwind before starting the fresh one so only
// one fetch owns the controller.
final inFlight = _currentFetchCompleter;
if (isFetching && inFlight != null && !inFlight.isCompleted) {
await inFlight.future;
if (useSafeMode && !mounted) return;
debugAssertNotDisposed();
}
await _fetchFirstPage(operation: 'refresh');
}