updateValue method
Update the paged value by loading a new page and combining it with the existing paged value.
Users should call loadPage or reload to actually update the page value.
Implementation
@protected
Future<void> updateValue({
bool isInitialLoad = false,
bool isReload = false,
}) async {
if (state.hasReachedEnd && !isReload) return;
if (state.value.isLoading && !isInitialLoad) return;
state = PagedValue(
hasReachedEnd: state.hasReachedEnd,
value: AsyncValue<List<T>>.loading().copyWithPrevious(state.value),
);
try {
final value = await getPagedValue();
final combinedValue =
combineList(!isReload ? state.value.valueOrNull : null, value);
state = PagedValue(
hasReachedEnd: hasReachedEnd(value),
value: AsyncValue<List<T>>.data(combinedValue)
.copyWithPrevious(state.value),
);
} catch (e, s) {
state = PagedValue(
hasReachedEnd: state.hasReachedEnd,
value: AsyncValue<List<T>>.error(e, s).copyWithPrevious(state.value),
);
}
}