添加后:
return SliverList(
delegate: SliverChildBuilderDelegate((contextSli, indexSli) {
ListView
变得无限(项目结束并重新开始)。
如何修复列表无穷大?
Widget build(BuildContext context) {
return SliverList(
delegate: SliverChildBuilderDelegate((contextSli, indexSli) {
return ListView.builder(
physics: physics,
shrinkWrap: shrinkWrap,
itemCount: itemCount,
controller: controller,
reverse: reverse,
primary: primary,
itemBuilder: (context, i) {
final TimelineModel model = itemBuilder(context, i);
model.isFirst = reverse ? i == (itemCount - 1) : i == 0;
model.isLast = reverse ? i == 0 : i == (itemCount - 1);
switch (position) {
default:
return TimelineItemLeft(properties: properties, model: model);
}
});
}),
);
}
SliverChildBuilderDelegate
它本身是一个列表构建器,因此您最终会得到一个列表中的列表(无限)。它会是这样的: