When should I implement my own `LazyLayout` over `...
# compose
k
When should I implement my own
LazyLayout
over
SubcomposeLayout
or even
Layout
? If I don't need to size it based off of children, does the answer change?
z
First factor is use case and performance: lazy layouts are much slower than eager ones if everything fits on the screen at once. Only use lazy layouts if you have so much content that composing it all at once is actually going to have a worse performance impact.
As for custom vs built in, depends what you need. If you’re building something that only composes part of its content at any given time, especially if that content is mostly homogeneous, probably
LazyLayout
. Use
SubcomposeLayout
directly when you need to defer the decision about what to compose based on eg available space but that content is mostly static (eg like Material’s Scaffold).