What's the point of listview nested column in flutter

In the last article, I wrote about the nested listview in the column. Today is the opposite.

In Flutter,  ListView nesting Column is also a common layout method. But when using this layout method, you need to pay attention to the following points:

One of the important details is that when using a Column in a ListView, the Column should be wrapped in an Expanded widget .

Otherwise, this could cause unwanted scrolling behavior or layout errors due to the Column's size being the sum of the sizes of its child elements. Also, if there are multiple child elements inside the Column, each child element should be wrapped with Flexible instead of Expanded so that they can adapt to their available space.

Another detail to note is that when using ListView, you should try to avoid using widgets with fixed heights in the list items , such as SizedBox and Container.

This is because in large amounts of data, these widgets can cause performance issues and may even cause the application to crash. Instead, try to use flexible widgets such as Expanded and Flexible so that they can adapt to their available space.

One final detail to note is that when using a ListView, you should avoid nested scroll views such as NestedScrollView and SingleChildScrollView within list items. This is because these widgets break the ListView's scrolling behavior and can cause layout errors and performance issues. If you need to achieve nested scrolling effects, please consider using other widgets, such as PageView.

Mastering these 3 precautions will play a key role in your drawing interface.

Guess you like

Origin blog.csdn.net/qq_28563283/article/details/130653453