DEV Community

Md . Jahid Hasan Naiem
Md . Jahid Hasan Naiem

Posted on • Updated on

Modify items in paginated list in Jetpack Compose

When utilizing the paging library to retrieve a list and subsequently populate the user interface with the paging list, modifying individual items from the list can pose considerable challenges. This tutorial aims to present a solution to this issue by demonstrating how custom pagination can be used to accomplish the same task with ease in Jetpack Compose.

Let's get started...

For this tutorial I have followed one of the tutorial by Philipp Lackner. How to Implement Pagination With Jetpack Compose - Android Studio Tutorial

So, I have replaced paging 3 library with this custom pagination. Also declared a data class for updating screen state. Also declared a CompositionLocal key that can be provided using CompositionLocalProvider.

After that used that screen state as a composable state in the ViewModel. Also declared a paginator of type DefaultPaginator.

I have used CompositionLocalProvider and wraped the root composable function with the provider. You can learn about CompositionLocalProvider from here..

So, whenever a clip gets played the value of the state declared in the ViewModel getting updated and causing Compose to recompose the screen.And the item from the list get modified.

This is it for today!

Top comments (0)