SwiftUI LazyVStack vs VStack
If we want to load the content into memory when we need it, we can use LazyVStack. It is particularly useful when we have large list of contents inside a scrollview.
Here’s how our regular VStack looks like:
VStack has 1000 Text content in it and the background color of VStack is blue:
And this is the memory report I have at first launch of my simulator:
Now back to LazyVStack:
Exactly same setup, I only replaced VStack with LazyVStack and here’s the result:
See that LazyVStack has flexible width and it covers all the screen whereas VStack fits in its context. With LazyVStack, in this example, we can scroll vertically by dragging anywhere on the screen.
And the memory report at first launch of my simulator: