blakelee

    blakelee

    1 year ago
    I have a simple toggle that increment or decrements based on clicking + or -. The preview interaction doesn’t do anything but if I run it on device it works fine. Is there something that I’m missing in this example to make it work in the preview?
    @Preview
    @Composable
    fun Counter() {
        var count by remember { mutableStateOf(0) }
        Row {
            Image(vectorResource(R.drawable.ic_remove), Modifier.clickable { count-- })
            Text(text = count.toString(), modifier = Modifier.align(Alignment.CenterVertically))
            Image(vectorResource(R.drawable.ic_add), Modifier.clickable { count++ })
        }
    }
    gildor

    gildor

    1 year ago
    Maybe it fails because of vector resource?
    blakelee

    blakelee

    1 year ago
    I’ll take it out and give it a shot. EDIT: Even changing it to text it works in app but not the preview.
    Invalidating cache fixed the issue. I guess it was a compose cache issue