When I create new project and select "Empty Compose Activity (Material3)", I can't use OutlinedTextField.
When I create new project and select "Empty Compose Activity" it's Ok
Why there is a different and how can I fix this?
CodePudding user response:
In your build.gradle
upgrade the Material3 dependency to the latest as below.
implementation 'androidx.compose.material3:material3:1.0.1'
This shows OutlinedTextField
in the project.
You must also add the @OptIn(ExperimentalMaterial3Api::class)
to your function as below.
@OptIn(ExperimentalMaterial3Api::class)
OutlinedTextField(
value = text,
onValueChange = { text = it },
)