Search code examples
flutterdartflutter-listview

how to detect middle or three quarters of scroll position on ListView on Flutter to lazy loading data?


how to detect middle or three-quarters of scroll position on ListView? I want to get data after reach to middle or three-quarters of the scroll position. How to do it?

Currently, I get data on the end of listView.

_scrollController.addListener(scrollListener);

  void scrollListener(){
    if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
      getMoreData();
    }
  }

Solution

  • I think this would work..

    _scrollController.addListener(scrollListener);
    
      void scrollListener(){
        if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent * 0.75) {
          getMoreData();
        }
      }