https://kotlinlang.org logo
#compose
Title
# compose
e

elye

02/08/2022, 11:54 AM
Hi @Doris Liu, an animation related inquiry. I can’t seems to find any additional benefit of
MutableStateTransition
compare to normal
mutableStateOf
has to offer. It’s long to describe here, so I have put the inquiry on StackOverflow https://stackoverflow.com/questions/71033419/whats-the-use-of-mutablestatetransition-looks-like-mutablestateof-does-all-i. Hopes to get some insight from you. Thanks 🙏
Thanks @Doris Liu for the answer. Excellent example indeed.
Copy code
val currentState = remember {
        MutableTransitionState(BoxState.Collapsed).apply {
            targetState = BoxState.Expanded
        }
    }
makes full sense. I think the example code in https://developer.android.com/jetpack/compose/animation#updateTransition should use the above instead of
Copy code
// Start in collapsed state and immediately animate to expanded
var currentState = remember { MutableTransitionState(BoxState.Collapsed) }
currentState.targetState = BoxState.Expanded
val transition = updateTransition(currentState)
// ...
2 Views