Pagination Without Paging 3 In Jetpack Compose.

Jayant Kumar🇮🇳
5 min readSep 6, 2024
Photo by David Thielen on Unsplash

Well , whenever we have to perform pagination in android development we use any library (paging 3) for that. But in this article we will see how to perform pagination without using any library.

Before proceeding, if you are not aware about pagination then….

Pagination means loading small chucks of data at a time and when you scroll down, another small chucks of data loads and so on….. through this way we improve the performance of our app.

You can also read about how to use paging3 library in android development

What we will do…

We will make a simple application , where we fetch list of data from the api.

How we will perform pagination?

Well, first time when we hit the api we pass page no. 1 , after that when we reached at the end of the list then we call the api again with page no. 2 and whatever data get , we append with the existing list, same process will continue till the api get the the empty response or failed.

Api Service

 interface ApiService {

@GET(Constants.API_END_CREDIT_TRANSACTION)
suspend fun getCreditTransaction(
@Query("page") page: Int,
): Response<List<CreditTransaction>>

}

--

--

Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳