androidkotlinandroid-jetpackandroid-pagingandroid-paging-library

How to mark end of dataset in android paging 3 library?


I am trying to use Android new Paging 3 Library in my app. I am fetching data from a backend API using Retrofit, which returns a list of objects. I need to know how to inform Pager to stop loading more data when the API returns an empty list.


Solution

  • When you have empty list, you should return nextKey = null in LoadResult.Page(...) to the Paging3 will know that there is no data further to load