setEnabled method
Enables or disables automatic loading.
Disabling invalidates in-flight replace operations and parks the controller at PageableStatus.COMPLETED when it holds no data; enabling with no data triggers fetchFirstPage and resumes polling.
Implementation
Future<void> setEnabled(bool enabled) async {
trackOperation('setEnabled');
debugAssertNotDisposed();
if (_enabled == enabled) return;
_enabled = enabled;
if (!enabled) {
_requestId += 1;
_debounceTimer?.cancel();
stopPolling();
value = value.copyWith(clearError: true);
if (!value.hasData) {
value = value.copyWith(status: PageableStatus.COMPLETED);
}
return;
}
if (!value.hasData && value.status == PageableStatus.COMPLETED) {
await fetchFirstPage();
}
startPolling();
}