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
Ben Trengrove [G]
07/21/2023, 5:23 AM
This is explained really well in this video
https://www.youtube.com/watch?v=OeC5jMV342A▾
s
StavFX
07/21/2023, 5:35 AM
This is great! Thanks Ben!
StavFX
07/21/2023, 5:53 AM
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?
StavFX
07/21/2023, 6:01 AM
e.g.
b
Ben Trengrove [G]
07/21/2023, 6:08 AM
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
StavFX
07/21/2023, 6:33 AM
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
Stylianos Gakis
07/21/2023, 6:45 AM
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.