Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference for Modifier.preferredSize and Modifier.prefferredHeight

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

like image 550
Tonnie Avatar asked Aug 21 '21 08:08

Tonnie


Video Answer


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

like image 156
Philip Dukhov Avatar answered Nov 15 '22 01:11

Philip Dukhov


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

like image 39
Gabriele Mariotti Avatar answered Nov 15 '22 00:11

Gabriele Mariotti