Jorge Domínguez

    Jorge Domínguez

    10 months ago
    hi all!, does anybody know how can I restart a Transition?
    val currentState = remember {
        MutableTransitionState(TransitionState.START)
            .apply { targetState = TransitionState.END }
    }
    val transition = updateTransition(currentState, label = "")
    the initial composition triggers the transition but I need to restart it whenever a Canvas draws something, which happens some time after the initial Transition is triggered. I've tried doing
    currentState.targetState = TransitionState.END
    right before drawing inside the Canvas but it doesn't work.
    Doris Liu

    Doris Liu

    10 months ago
    You could either 1) pass a new MutableTransitionState instance to updateTransition, which will restart the transition, or 2) add a
    key
    around
    updateTransition
    and change the key param to restart
    Jorge Domínguez

    Jorge Domínguez

    10 months ago
    I went for the first one but the
    key
    also sounds like a suitable solution. Thanks!