Home > OS >  I cannot use TextField() in jetpack Compose(Material 3)
I cannot use TextField() in jetpack Compose(Material 3)

Time:10-29

@Composable
fun EditNumberField() {
    TextField(value = "", onValueChange = {}){
        
    }
}

It says Unresolved reference: TextField.

I want a TextField so that the user can enter a value but it is showing an error.

CodePudding user response:

Check your dependencies in the build.gradle file. You have to add the library:

implementation "androidx.compose.material3:material3:$material3_version"

Also check your import statements in your class:

import androidx.compose.material3

If you are using M2 and M3 together avoid this kind of import of both packages together:

import androidx.compose.material.*
import androidx.compose.material3.*
  • Related