tp7309 / flutter_sticky_and_expandable_list

粘性头部与分组列表Sliver实现 Build a grouped list, which support expand/collapse section and sticky headers, support use it with sliver widget.
MIT License
140 stars 29 forks source link

使用controller去跳转的话,应该怎么去计算每个区域的位置,需要计算header的高度吗? #12

Closed fangshengfy closed 4 years ago

fangshengfy commented 4 years ago

当前的header应该还在列表中占据位置吧?

tp7309 commented 4 years ago

可以参考这个: https://github.com/tp7309/flutter_sticky_and_expandable_list/issues/8

fangshengfy commented 4 years ago

可以参考这个:

8

在第一次进入页面且未滚动时controller.containerOffsets拿到的offset是0或者拿不到,滚动一下页面或者热更新一下就好了,我没隐藏list

fangshengfy commented 4 years ago

应该是出现在section单个的高度超出视口时,只有0和1拿到的offset为0,超过的话就是超出数组范围

fangshengfy commented 4 years ago

我设置section的item为1时是没有问题的

tp7309 commented 4 years ago

没显示过的的列表项拿不到偏移量,因为还没new出来。如果固定高度的话可以自己计算一下偏移量。

fangshengfy commented 4 years ago

偏移量的计算公式是什么?我不太清楚header的高度计算该怎么算

tp7309 commented 4 years ago

控件的高度都可以自己写死,比如示例工程中一个Header下有五个ListTile,Header高度设置为20,每个ListTile高度为10,那么每个组(section)的高度就是20+10x5=70,section==3时偏移量就是3x70=210.

fangshengfy commented 4 years ago

好的谢谢

tp7309 commented 3 years ago

I have added an example of scroll to index.