Solve rememberRipple has been deprecated Error

Today, I encountered an error when integrating the rememberRipple() method to enable the ripple effect on the Box widget in Kotlin Compose Multiplatform (KMP). Due to this error, the ripple effect widget displays a warning message about depreciation. Also, the project did not run when I applied the old, deprecated rememberRipple() method. So, after reading the new documentation of the Material library, I found the solution.

Solve rememberRipple has been deprecated Error

Solve rememberRipple has been deprecated Error:

This is what the error looks like:

@Deprecated(level = DeprecationLevel.ERROR, message = “rememberRipple has been deprecated – it returns an old Indication implementation that is not compatible with the new Indication APIs that provide notable performance improvements. Instead, use the new ripple APIs provided by design system libraries, such as material and material3. If you are implementing your own design system library, use createRippleNode to create your own custom ripple implementation that queries your own theme values. For a migration guide and background information, please visit developer. android. com”)
@Suppress(names = {“DEPRECATION”, “TYPEALIAS_EXPANSION_DEPRECATION”})
@Composable
public fun rememberRipple(
bounded: Boolean = true,
radius: Dp = Dp.Unspecified,
color: Color = Color.Unspecified
): Indication

Code with Error:

Code with Solution:

Complete source code for App.kt file:

Screenshot:

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *