Flutter滚动布局嵌套高度自适应和滑动冲突处理

在SingleChildScrollView中嵌套ListView,如果不指定ListView高度的话会报错,类似这样的

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during paint():
RenderBox was not laid out: RenderViewport#a8f36 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1702 pos 12: 'hasSize'

解决方法有两种:

  • 用有高度的布局(如Container)将ListView包裹,然后指定可滚动高度

你可能感兴趣的:(Flutter)