Ashu
08/22/2021, 8:00 AMModifier.onSizeChanged
(or globally positioned) and the other one is to use BoxWithConstraints
, but I am not sure when to use which. Can someone provide examples of use-cases of both of these. The examples should be such that only one of these is a perfect fit for that scenario. Thanks :)Zach Klippenstein (he/him) [MOD]
08/22/2021, 2:52 PMonSizeChanged
if you need the size in order to compose the first frame of your content – the size won’t be available until after the measure pass, which only happens after the first composition pass. And on the other side of that, if you only need to know the size later, e.g. when handling a particular event, then BoxWithConstraints
is unnecessary and may cause recompositions you don’t need since it will recompose every time your constraints change.Colton Idle
08/23/2021, 12:21 AMAlbert Chang
08/23/2021, 3:01 AMBoxWithConstraints
if you want to have difference structures for different sizes. If you just want to for example change the sizes of children according to parent size, using a custom layout is more performant.