我想在到达ListView的底部后导航到下一页,当我第一次导航是可行的,但是当我再次尝试时,它会失败并显示此错误:
ScrollController attached to multiple scroll views.
Failed assertion: line 111 pos 12: '_positions.length == 1'
我读了几则帖子,例如post1,但找不到解决方法。
这是我的实现:
double previousScrollOffset = 0.0;
ScrollController _controller;
@override
void initState() {
// TODO: implement initState
super.initState();
_controller = ScrollController( initialScrollOffset: previousScrollOffset);
_controller.addListener(() {
if (_controller.position.atEdge) {
if (_controller.position.pixels == 0) {
// you are at the top
print('You are at the top');
} else {
//bottom
// previousScrollOffset = _controller.offset;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => CustomSwipeDownPage()),
);
}
}
});
}
然后,这就是我在ListView
内的称呼方式:
ListView(controller: _controller)
解决方案是什么?