animateIntAsState

Functions summary

State<Int>
@Composable
animateIntAsState(
    targetValue: Int,
    animationSpec: AnimationSpec<Int>,
    label: String,
    finishedListener: ((Int) -> Unit)?
)

Fire-and-forget animation function for Int.

Cmn

Functions

animateIntAsState

@Composable
fun animateIntAsState(
    targetValue: Int,
    animationSpec: AnimationSpec<Int> = intDefaultSpring,
    label: String = "IntAnimation",
    finishedListener: ((Int) -> Unit)? = null
): State<Int>

Fire-and-forget animation function for Int. This Composable function is overloaded for different parameter types such as Dp, Color, Offset, etc. When the provided targetValue is changed, the animation will run automatically. If there is already an animation in-flight when targetValue changes, the on-going animation will adjust course to animate towards the new target value.

animateIntAsState returns a State object. The value of the state object will continuously be updated by the animation until the animation finishes.

Note, animateIntAsState cannot be canceled/stopped without removing this composable function from the tree. See Animatable for cancelable animations.

Parameters
targetValue: Int

Target value of the animation

animationSpec: AnimationSpec<Int> = intDefaultSpring

The animation that will be used to change the value through time. Physics animation will be used by default.

label: String = "IntAnimation"

An optional label to differentiate from other animations in Android Studio.

finishedListener: ((Int) -> Unit)? = null

An optional end listener to get notified when the animation is finished.

Returns
State<Int>

A State object, the value of which is updated by animation.