setListResult method

void setListResult(
  1. String queryKey,
  2. List<String> ids, {
  3. String? entityType,
  4. int? total,
  5. String? nextCursor,
  6. String? prevCursor,
  7. bool hasNextPage = false,
  8. bool hasPrevPage = false,
})

Implementation

void setListResult(
  String queryKey,
  List<String> ids, {
  String? entityType,
  int? total,
  String? nextCursor,
  String? prevCursor,
  bool hasNextPage = false,
  bool hasPrevPage = false,
}) {
  _write(() {
    if (entityType != null) _listTypes[queryKey] = entityType;
    final prev = _lists[queryKey] ?? ListState.empty;
    _lists[queryKey] = prev.copyWith(
      ids: List.unmodifiable(ids),
      total: total,
      nextCursor: nextCursor,
      prevCursor: prevCursor,
      hasNextPage: hasNextPage,
      hasPrevPage: hasPrevPage,
      isFetching: false,
      isFetchingMore: false,
      lastFetched: DateTime.now(),
      stale: false,
      clearError: true,
      clearTotal: total == null,
      clearNextCursor: nextCursor == null,
      clearPrevCursor: prevCursor == null,
    );
    _notifyList(queryKey);
  });
}