I'm new and beginner in Android Programming especially kotlin and jetpack compose, I'm following some tutorial about how to make a search bar but there is some main issue that I'm facing right now, that is the SearchBar function didn't exist nowadays even though the tutorial that I watched is 2 months ago. this is the code
package com.example.searchbarfinal
import android.annotation.SuppressLint
import android.graphics.drawable.shapes.Shape
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
fun SearchBar(
query: String,
onQueryChange: (String) -> Unit,
onSearch: (String) -> Unit,
active: Boolean,
onActiveChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
shape: Shape = SearchBarDefaults.inputFieldShape,
colors: SearchBarColors = SearchBarDefaults.colors(),
tonalElevation: Dp = SearchBarDefaults.Elevation,
windowInsets: WindowInsets = SearchBarDefaults.windowInsets,
IOnteractionSource: MutableInteractionSource = remember {MutableInteractionSource()},
content: @Composable ColumnScope.() -> Unit
){
}
@Composable
fun MainScreen() {
Scaffold() {
SearchBar(
query = ,
)
}
}
Unresolved reference: SearchBarDefaults Unresolved reference: SearchBarColors
and for the function of SearchBar I'm making manually instead calling automatically, can you guys please provide me some advice or help guys? Im using material 3 jetpack compose
thank you everyone
There is no SearchBar, SearchBarDefault, SearchBarColor in the material3 Jetpack Compose
Which version of Material 3 are you using? You need at least version 1.1.0 as SearchBar was a new component then. Ideally, use this implementation "androidx.compose.material3:material3:1.1.1
.