The result I want to achieve, is to trigger a lazy loading function before user reaches scrollController.position.maxScrollExtent, so in that way I will "minimize" the waiting time in the eyes of user.
In my case, I want the lazy loading function to trigger every time users scroll an 80% of the screen
Here is my working code snippet with lazy loading function triggered when user reaches the end of the screen (classic way):
scrollController.addListener(() {
if (scrollController.position.pixels == scrollController.position.maxScrollExtent) {
print('bottomReached');
// lazy load function
}
});
I tried to change the if statement to this:
scrollController.position.pixels >= scrollController.position.maxScrollExtent*0.8
but it didn't work as expected. What else can I do ? Thanks in advance.