Is there a rule of thumb to choose `Column` with `...
# compose
l
Is there a rule of thumb to choose
Column
with
Modifier.verticalScroll()
or
LazyColumn
? Seems for every scrollable page we can just use
LazyColumn
, but the `item {}`makes the development a little bit cumbersome, can I just use
Column
for the pages which don’t have infinite scrollable content?
d
Column
will compose and layout every child, while
LazyColumn
will only layout what is visible (hence lazy), so i’d say it depends on the number of items
l
thanks for the clarification, but the tough thing is what's the threshold for the number? how many items when a page reach I should switch from Column to LazyColumn? 🤣
s
AFAIK, you can't nest a
LazyColumn
inside a scrollable
Column
yet, so if you need to display a list within a scrollable
Column
, go for a plain
Column
👍 1
c
I asked this question like a year ago and the gist of it seemed to be: 1. it can show intent a bit more clearly by using one api over the other 2. in simple cases (stacking two texts on top of each other) there really isn't any benefit of not using a Column 3. There is some overhead to using a Lazy. so if you don't need it, dont use it. Ill try to find the question though. it had some good input from compose team.
l
oh, thank Colton for the reference, I think now I understand more about the API design, maybe for most pages if there isn’t a big performance issue I would just go with Column.😁
c
Yeah. Personally I've been going for column almost everywhere except when I see that there is lag in release builds. if I see lag, then I convert to a lazy and then the issue goes away. so its almost like a trick i keep in my back pocket at this point for a quick win for perf improvement.
🤣 1
but yes. you could argue that i should just make everything lazy right off the bat. lol
c
cc @Ben Trengrove [G]
b
There is no hard and fast rule but the general idea is - with lazy you pay a higher cost per visible item than non-lazy but you will only have items for what can be seen on screen. With Column, you pay a low cost per item but if you have a lot of them thats going to add up pretty fast. Roughly, if you know you will never have that many items then Column/Row is probably all you need. Like most things though you just have to test it out (in release not debug) and see.
💯 2