how to load data when Some scrolls from api for flutter

Hello all,

In this discussion, we will see how to handle the Screen Scrolls and, by that, call the API on particular scrolls.

var _controller = ScrollController();

declare the above ScrollController in the class, Then Write below Function in inti function.

_controller.addListener(() {
  if (_controller.position.pixels > 1600 && _controller.position.pixels < 1900) {
    if(workedon==0) {
      // function you want to 
    }

  } 

});

After then the function we want to call will work on, Basically it will check the scrolls and if it's between the arranged pixels then the condition will get true and runs.

Total example:

var _controller = ScrollController();
@override
void initState() {
  super.initState();
_controller.addListener(() {
  if (_controller.position.pixels > 1600 && _controller.position.pixels < 1900) {
    if(workedon==0) {
      workedon=1;
    }

  }
  // setState(() => _physics = ClampingScrollPhysics());

});
}

Thank you.

Tagged:
Sign In or Register to comment.