Search code examples
androidmaterial-designandroid-jetpack-composeandroid-jetpack-compose-material3

Jetpack Compose Material3 Pull to Refresh functionality


I am trying to migrate a project from Material2 specs to Material 3 compose library following this guide.

The current LazyColumn in Material2 has integrate Pull to refresh functionality, found here

However, i did not find any such functionality for Material3. There is an issue tracker open here but they say this functionality will be considered only mid this year, which is too long to wait.

Does anyone have any idea on how this situation should be handled? Pull to refresh is an important flow of our apps user flow, so not having it is not an option.

Should we use accompanist/swipeToRefresh even though it is deprecated?

I am not proficient in writing custom compose components yet, so any help in figuring this out would be appreciated


Solution

  • Our team ran into this same problem. Ultimately, we opted to bring the MD2 implementation of the PullToRefresh component into our project as a temporary workaround. Then, we just updated any MD2 references to their MD3 counterparts.

    The full MD2 implementation consists of the following files:

    • PullRefresh.kt
    • PullRefreshIndicator.kt
    • PullRefreshIndicatorTransform.kt
    • PullRefreshState.kt

    This approach was suggested in this discussion. You can find the op's full solution here.