• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

"Not enough information to infer type variable T" android studio error

6gBPr7k
I'm following a series of kotlin based tutorials on youtube for android studio jetpack compose, but now android studio is giving me the error "Not enough information to infer type variable T" for keyframes, while everything is exactly copied from the tutorial video, what am i doing wrong?

Code:
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            var sizeState by remember { mutableStateOf(200.dp) }
            val size by animateDpAsState(
                targetValue = sizeState,
                keyframes {
                    durationMillis = 5000
                    sizeState at 0 with LinearEasing
                    sizeState * 1.5f at 1000
                    sizeState * 2f at 5000
                }

            Box(modifier = Modifier
                .size(size)
                .background(Color.Red),
            contentAlignment = Alignment.Center) {
                Button(onClick = {
                    sizeState += 50.dp
                }) {
                    Text("Increase Size")
                }
            }

        }
    }
}

6gBPr7k
 
Last edited:
Back
Top Bottom