1.介绍:
flutter中布局使用了listview的ListView.builder构建,列表除了第一项,其他用了ExpansionTile。
2.报错:
'package:flutter/src/rendering/sliver_list.dart': Failed assertion: line 270 pos 14: 'estimatedMaxScrollOffset >= endScrollOffset - childScrollOffset(firstChild)': is not true.
3.复现:
把列表中每一个ExpansionTile从下往上展开,然后从下往上折叠,当折叠到最后一两个的时候会报上面的错。
4.我的解决办法:
用另外一个listview嵌套这个listview
ListView(children: <Widget>[
ListView.builder(
shrinkWrap: true, //为true可以解决子控件必须设置高度的问题
physics:NeverScrollableScrollPhysics(),//禁用滑动事件
itemCount: (_showWordTypeList?.length ?? 0) + 1,
itemBuilder: (BuildContext context, int index) {
return index == 0
? buildHeader(context)
: _buildWordTableTypeList(
context, _showWordTypeList[index - 1], index - 1);
}),
],),
网友评论