In Flutter I have a SingleChildScrollView with a column as the child. Inside that column is 3 widgets: A ListView.separated widget, a sized box, and a different ListView.separated widget.
The ListView.separated widgets have shrinkWrap set to true and physics set to NeverScrollableScrollPhysics() to allow the SingleChildScrollView to handle scrolling.
My question is, are the two ListView widgets loaded lazily (on demand) or does the SingleChildScrollView and column parent mean they are loaded in full when the page loads?
CodePudding user response:
As per My Understanding ,The Size Would have been Assigned to the Page At LoadTime, or When The Builder Runs, So Single Child Scroll View Just Assumes It have Fixed Height or Width, Rest the ListView Behaves as Usual.
CodePudding user response:
are the two ListView widgets loaded lazily (on demand)?
the answer is NO. this is what the documentation said:
so that the lazy instantiation of a sliver-based ListView or CustomScrollView is not expected to provide any performance benefit.
more explanation TL;DR
its not recommend to wrap ListView
inside SingleChildScrollView
, except your ListView
expected to fit on the screen.
SingleChildScrollView :
This widget is useful when you have a single box that will normally be entirely visible
If the viewport is expected to usually contain content beyond the dimensions of the screen, then SingleChildScrollView would be very expensive.
it recommends using the SingleChildScrollView
when the child has finite height (around screen height).
When you have 2 or more ListView.separated
widget that has big dimensions, it would be better to wrap with ListView
. Do not using SingleChildScrollView
.