https://kotlinlang.org logo
#compose
Title
# compose
r

Rick Regan

01/10/2021, 10:23 PM
When I call this composable I get two messages: ... Slider onValueChange: 10.0 ... Slider onValueChange: 5.0 I was expecting only one callback, the second one.
Copy code
@Composable
fun SliderTest() {
    val sliderValue = remember { mutableStateOf(5f) }
    Slider(
            value = sliderValue.value,
            onValueChange = {
                Log.d("Slider onValueChange ", "$it")
                sliderValue.value = it
            },
            modifier = Modifier.width(200.dp),
            valueRange = 0f..10f,
    )
}
The first message is always for the end value in valueRange, 10 in this example. (I'm using Arctic Fox 2020.3.1 Canary 4, built on Dec 23, 2020.)
t

Thomas

01/10/2021, 10:26 PM
Both messages should not appear, it is a known bug. See: https://issuetracker.google.com/issues/175943373
r

Rick Regan

01/10/2021, 10:37 PM
Thanks for the quick response. (I'll try to do a better job of finding open bugs next time.)
4 Views