Pagination with SatggeredGridview Flutter

Viewed 524

How to implement Staggered Gridview with Pagination using Json Api . I want to load data per page 10 . How to implement This . Any one please give me some suggestions or examples.

1 Answers

Satggered widget have the same behaviors in ListView, I built it with Controller

the controller

ScrollController _scrollController = new ScrollController();

and add listener in iniState to do something when the scroll arrives to the bottom

      @override
  void initState() {
    super.initState();
    _scrollController.addListener(() {
      if(_scrollController.position.pixels == _scrollController.position.maxScrollExtent){
        //if we are in the buttom of the page
        //Here get the data tha you wanna get it and set it in array and call
        setState((){});
      }
    });
  }

and at the end set the controller in the Satggered

StaggeredGridView.countBuilder(
                          controller: _scrollController,),

I hope that was useful

Related