SingleChildScrollView使用注意事项

因为 SingleChildScrollView的属性scrollDirection默认是
Axis.vertical,

所以如果child为Row的话,就会报错

======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 324 pixels on the right.

The relevant error-causing widget was: 
  Row Row:file:///xx/item_widget.dart:25:18
The overflowing RenderFlex has an orientation of Axis.horizontal.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

所以此处要注意:
修改属性scrollDirection为
scrollDirection: Axis.horizontal

你可能感兴趣的:(Flutter,flutter)