I want to disable ripple effect of a button, reading this document Migrate to Indication and Ripple APIs. in Says to replace this code
private object DisabledRippleTheme : RippleTheme {
@Composable
override fun defaultColor(): Color = Color.Transparent
@Composable
override fun rippleAlpha(): RippleAlpha = RippleAlpha(0f, 0f, 0f, 0f)
}
// ...
CompositionLocalProvider(LocalRippleTheme provides DisabledRippleTheme) {
Button {
// ...
}
}
with this code
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Button {
// ...
}
}
but the newer code does not work in my case is there a version limitation to this code?
i tried to override RippleTheme, but i got this error Using 'RippleTheme' is an error. RippleTheme and LocalRippleTheme have been deprecated
Yes, there is a version limitation to this new API. In the document you have linked:
The following library versions include a ripple behavior change:
androidx.compose.material:material:1.7.0+
androidx.compose.material3:material3:1.3.0+
androidx.wear.compose:compose-material:1.4.0+
These dependencies are still in beta, the most recent Compose BOM 2024.06.00 includes material:1.6.8
and material3:1.2.1
.
Edit:
So if you want to use the new APIs now, specify versions for these dependencies directly:
implementation("androidx.compose.material:material:1.7.0-beta06")
implementation("androidx.compose.material3:material3:1.3.0-beta05")
It's important to not forget to remove these versions as soon as they are out of beta and included in Compose BOM! You can check BOM version mapping here.