Unresolved reference for Modifier.preferredSize and Modifier.prefferredHeight

Viewed 642

I am following this YouTube Tutorial where they are using Modifier.preferredSize() on a box and Modifier.preferredHeight() on a Spacer Composable - all other chained Modifiers are fine.

However Android Studio is not recognizing these 2 options.

Here is the code that I am working with:

enter image description here

I am using compose_version = '1.0.1' and I'm on AS Arctic Fox

2 Answers

preferredSize was renamed to size and preferredHeight to height

If I face some old video/article with invalid api, I'm searching through compose-samples(official samples from the maintainers) commits to find place where this method was deprecated/renamed, it's the easiest way to know if it just was renamed or I need to change more logic. In this case change was on this commit

Modifier.preferredWidth/preferredHeight/preferredSize were renamed to width/height/size starting from 1.0.0-beta01

Related