Skip to content

Migrating to material3 1.5.0 — deprecations

Short answer: the most common warnings after upgrading to 1.5.0-beta02 come from four APIs:

  • ListItem(headlineContent = …) → put the headline in the trailing content lambda
  • the old SearchBar/DockedSearchBar → SearchBar(state, inputField) with an expanded search bar
  • TopSearchBar → AppBarWithSearch
  • non-state Slider overloads → Slider(state, …)
@Composable
fun WifiRow(network: String, onClick: () -> Unit) {
// 1.5.0: the headline is the trailing content lambda. ListItem(headlineContent = …) is deprecated.
// The onClick overload makes the whole row clickable with the right semantics.
ListItem(onClick = onClick, supportingContent = { Text(network) }) {
Text("Wi-Fi")
}
}
@Composable
fun AppSearch(suggestions: (String) -> List<String>, onSearch: (String) -> Unit) {
// State-based search bar. The old SearchBar(query, onQueryChange, active, …) is deprecated.
val searchBarState = rememberSearchBarState()
val textFieldState = rememberTextFieldState()
val scope = rememberCoroutineScope()
val inputField = @Composable {
SearchBarDefaults.InputField(
textFieldState = textFieldState,
searchBarState = searchBarState,
onSearch = { query ->
onSearch(query)
scope.launch { searchBarState.animateToCollapsed() }
},
placeholder = { Text("Search") },
)
}
SearchBar(state = searchBarState, inputField = inputField)
ExpandedFullScreenSearchBar(state = searchBarState, inputField = inputField) {
LazyColumn {
items(suggestions(textFieldState.text.toString())) { suggestion ->
ListItem(
onClick = {
textFieldState.setTextAndPlaceCursorAtEnd(suggestion)
onSearch(suggestion)
scope.launch { searchBarState.animateToCollapsed() }
},
) { Text(suggestion) }
}
}
}
}

Colors renamed in ListItemColors, MenuItemColors → SelectableMenuItemColors, TextFieldLabelPosition.Attached, ripple alpha and more: API status: deprecated.

Want your agent to get this right every time? Install the skill. If this page helped,star the repo on GitHub.

Built by Sanikant. Set in Google Sans Flex (SIL Open Font License), icons from Material Symbols (Apache 2.0). Material Design is a Google trademark; this project is not affiliated with Google.