androidkotlinandroid-jetpack-compose

Material3 Slider not found


I am building a simple app with Jetpack Compose and in this app I have a slider:

Slider(value = procentTipState.value,
       onValueChanged = {
           newVal -> Log.d("Tip", "Tip procent $newVal")
       })

Android Studio LadyBug does not recognize this form of slider and expects something like this:

Slider(
        state = ,
        modifier = ,
        interactionSource =,
        thumb = ,
        track = 
    )

I am importing Slider:

import androidx.compose.material3.Slider

In build.gradle I have:

implementation(libs.androidx.material3)

The error is like this: Cannot find a parameter with this name: value

I have added @OptIn(ExperimentalMaterial3Api::class) annotation for the composable function that will use the slider.

Can anyone please give a hint in the right direction ?


Solution

  • You have a typo in onValueChanged, replace it with onValueChange (without the trailing d) and it should work just fine.