The slider `steps` parameter is not defined in the...
# compose
r
The slider
steps
parameter is not defined in the way I would expect. If I want a discrete slider to range from 0 to 12 in increments of 1, I would expect to specify steps = 12; however, I must specify steps = 11. Similarly, increments of 2 requires steps = 5 (not 6); increments of 3 requires steps = 3 (not 4); increments of 4 requires steps = 2 (not 3). The formula appears to be steps = (end - start)/increment - 1 when I would expect steps = (end - start)/increment. What is the rationale for the way it is defined?
Copy code
@Composable
fun DiscreteSliderTest() {
    Column {
        val sliderValue = remember { mutableStateOf(5f) }
        Slider(
                value = sliderValue.value,
                onValueChange = { sliderValue.value = it },
                modifier = Modifier.width(400.dp) .fillMaxWidth(),
                valueRange = 0f..12f,
                steps = 3,
                )
        Text(
                text = sliderValue.value.toString(),
        )
    }
}
By the way, in the code example, the slider starts out with value 5, even though it is between quantized values 3 and 6 (if you move the slider you will never get it back to 5). That does not seem to be the desired behavior.