Hello everyone) Tell me, is there some practical e...
# compose
e
Hello everyone) Tell me, is there some practical example when you need to use requiredSize modifier, but not size modifier. And is requiredSize always worth using when exact dimensions are needed?)
a
Modifier.requiredSize()
is only needed if you want to override the size specified by
Modifier.size()
before in a modifier chain.
Modifier.size(10.dp).size(5.dp)
makes the size 10dp and
Modifier.size(10.dp).requiredSize (5.dp)
makes the size 5dp.
today i learned 1
Or override the size coming from constraints, e.g. making an item 10dp in a 5dp box.
2
a
@Chris Sinco [G] I believe in that case
Modifier.size(24.dp)
will also work. Btw this is the bug.
👍 1
c
Ahhh that makes more sense. Required size was the workaround there 🤷🏻‍♂️
a
Another example is if you want to make a FloatingActionButton bigger than the size allowed by
Scaffold
(its parent), maybe for a transition animation. No matter how high of a value you put in
size
, it will still stay a weird rounded rectangle and not exceed a certain size. But if you use
requiredSize
, it will go bigger.
a
Yeah that’s exactly the second use case above.