1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by WhaleJesus, Feb 22, 2022.

  1. WhaleJesus

    WhaleJesus Lurker
    Thread Starter

    [​IMG] 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 (Text):
    1. class MainActivity : ComponentActivity() {
    2.     override fun onCreate(savedInstanceState: Bundle?) {
    3.         super.onCreate(savedInstanceState)
    4.         setContent {
    5.             var sizeState by remember { mutableStateOf(200.dp) }
    6.             val size by animateDpAsState(
    7.                 targetValue = sizeState,
    8.                 keyframes {
    9.                     durationMillis = 5000
    10.                     sizeState at 0 with LinearEasing
    11.                     sizeState * 1.5f at 1000
    12.                     sizeState * 2f at 5000
    13.                 }
    14.  
    15.             Box(modifier = Modifier
    16.                 .size(size)
    17.                 .background(Color.Red),
    18.             contentAlignment = Alignment.Center) {
    19.                 Button(onClick = {
    20.                     sizeState += 50.dp
    21.                 }) {
    22.                     Text("Increase Size")
    23.                 }
    24.             }
    25.  
    26.         }
    27.     }
    28. }
    [​IMG]
     


    #1 WhaleJesus, Feb 22, 2022
    Last edited: Feb 22, 2022

    1. Download the Forums for Android™ app!


      Download

       
  2. James_Watson

    James_Watson Android Enthusiast

    Did you miss a comma before "Box(modifier = Modifier..."?
     
Loading...

Share This Page

Loading...