Does it make sense that `Modifier.size(10.dp).size...
# compose
s
Does it make sense that
Modifier.size(10.dp).size(500.dp)
result in an actual size of 10dp? I expected the final result to be 500. (Yes, this is a non-sensical example, but it matters when playing with the .then() function)
b
This is explained really well in this video

https://www.youtube.com/watch?v=OeC5jMV342A

s
This is great! Thanks Ben!
so... this brings up something interesting. When I need to center something, many times I just happen to wrap it in a Box(fillMaxSize). But with "clever" use of modifiers, I can center my composable with
Modifier.fillMaxSize().wrapContentSize()
without wrapping in with a Box. Would there be any point to using the modifier approach? Is performance going to look any different?
e.g.
b
I think that the pure modifier one would be very slightly faster but that's just my gut instinct. I don't think there is really anything wrong with either
s
The Modifier one is too magicy for me and I'd rather not subject my fellow developers to read / maintain that code 😂
1
1
s
Alternatively, do use it and teach it to everyone. WrapContentSize/Width/Height is a super powerful modifier and sometimes is actually necessary to do some things. It's a very good idea to know how to use it.
🤔 2