load

To load data for the current page, nextKey and prevKey for params are both set to null to prevent automatic loading of by the PagingSource. This is done in order to explicitly allow loading of data by manually clicking navigation previous or next buttons.

To load all data (by automatically paginating the results in the background), set loadAll to true (Checking if data is not empty prevents querying for more results when there is none):

prevKey = if (pageNumber == 0) null else pageNumber - 1

nextKey = if (data.isNotEmpty()) pageNumber + 1 else null