is animate*AsState animating in Jetpack compose

Solution for is animate*AsState animating in Jetpack compose
is Given Below:

I want to get is animate*AsState is currently animating. But how? Example of this:

val shape = animateIntAsState(
        if (!isSelected) 50 else 20,
        animationSpec = TweenSpec(150, 0)
    )

Just put a condition. if (shape != 20 && shape != 50) return true else return false

For the animate*AsState functions, you would usually want to drive them using a boolean state variable. The animation itself can only be toggled between just two distinct values. You could rewrite your example as follows.

var isSelected by remember { mutableStateOf(false)}

val shape = animateIntAsState(
        if (!isSelected) 50 else 20,
        animationSpec = TweenSpec(150, 0)
)

You can then toggle the animation by changing the value of isSelected in response to either an event call such as onClick or a Side Effect call.