I have a scroll controller which checks if the scroll position passed the threshold and then call the function:
final _scrollController = ScrollController();
final _scrollThreshold = 200.0;
_scrollController.addListener(_onScroll);
void _onScroll() {
final maxScroll = _scrollController.position.maxScrollExtent;
final currentScroll = _scrollController.position.pixels;
if (maxScroll - currentScroll <= _scrollThreshold) {
dummyFunction();
}
}
Currently, dummyFunction() is called multiple times, How to make sure it is going to be called once?