I am currently paginating at max extent. I have written this code :
if (scrollController.position.pixels ==
scrollController.position.maxScrollExtent) {
setState(() {
startIndex = 10;
});
context.read<CollectionBloc>().add(
GetNewsCollectionFromBookmarks(startIndex),
);
}
I have tried this test also :
if (scrollController.position.pixels >
scrollController.position.maxScrollExtent - 200) {}
But it's making scroll very laggy
CodePudding user response:
== is not a good practice in this case. try using something like:
if (scrollController.position.pixels >
scrollController.position.maxScrollExtent - 200) {}
just you should handle in your stateful widget or your bloc not to fetch data multiple times.
CodePudding user response:
_scrollController.addListener(() {
if (_scrollController.position.isScrollingNotifier.value ||
_scrollController.position.extentAfter < 500) {
if (_scrollController.position.atEdge) {
if (_scrollController.position.pixels == 0) {
// You're at the top.
} else {
// you are at the above bottom
}
}
}
}
});
This may be helpful for you
