Blow the code, I want to set value to currentDegree on animate end, but when I do it, it recomposes. How to make it not recompose?
@Composable
fun RotateImageCompose(width: Dp, height: Dp, resId: Int, targetDegree: Float) {
val currentDegree = remember { mutableStateOf(0f) }
var diff = currentDegree.value - targetDegree
.
.
.
val dregree by animateFloatAsState(targetValue = diff, animationSpec = tween(
easing = LinearEasing,
durationMillis = 180
), finishedListener = {
//this code cause the issue
currentDegree.value = it
})
Image(
painter = painterResource(id = resId),
contentDescription = null,
modifier = Modifier
.rotate(dregree)
.size(width, height)
)
}