• 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

WhaleJesus

Lurker
Feb 22, 2022
1
0
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:

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones