Thread
#compose
    Rick Regan

    Rick Regan

    1 year ago
    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.
    @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.)
    Thomas

    Thomas

    1 year ago
    Both messages should not appear, it is a known bug. See: https://issuetracker.google.com/issues/175943373
    Rick Regan

    Rick Regan

    1 year ago
    Thanks for the quick response. (I'll try to do a better job of finding open bugs next time.)