ScrollController _scrollController = ScrollController();
void initState() {
super.initState();
_scrollController.addListener(() {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent) {
//滚动到底部
}else if(_scrollController.position.pixels <=
_scrollController.position.minScrollExtent){
//滚动到顶部
}
});
}
ListView.separated(
controller: _scrollController,
itemBuilder: (context, index) {
return _listItemView(index);
},
separatorBuilder: (context,index) =>Container(height: 5),
itemCount:_activitiesList.length)
flutter ListView判断滚动到了顶部和底部
最新推荐文章于 2024-08-25 16:38:39 发布