Is there any alernative for pagination in flutter?

Viewed 128

I need to build cards from the data that, I receive from REST API. When the data is getting increased, the cards are taking time to build and show on the screen. Is there any procedure to solve this problem?

Can we handle this by using a pagination or bloc pattern? If not what would be the better one to handle it?

1 Answers

Yes, you can do it by listening to scrolls. When the page scrolls, you can send a request to the service as you set it.

 @override
  void initState() {
  super.initState();
  _scrollController = new ScrollController()..addListener(_scrollListener);
  }

 _scrollListener() {
   if (_scrollController.position.extentAfter <= 0) {
     Provider.of<TryProvider>(context, listen: false)
      .setNextPage(1);

     //getPagelist...
     Provider.of<TryProvider>(context, listen: false)
      .getNextPage();     
   }
Related