简体   繁体   中英

Paggination on api data in flutter

i get data from API like demo:- {draw: 0, records Total: 210, records Filtered: 210, data: [,…], input: []} data: [,…] draw: 0 input: [] records Filtered: 210 records Total: 210

i want to apply paggination on API data(grid view or list view)how can i do that ?

Your json structure needs to look like this to apply pagination with ease. Use current page , next page and last page to determine the next, current and remaining pages.

You can directly use the next link to get the data of the next page.

{
  "meta": {
    "page": {
      "current-page": 2,
      "per-page": 15,
      "from": 16,
      "to": 30,
      "total": 50,
      "last-page": 4
    }
  },
  "links": {
    "first": "http://localhost/api/v1/posts?page[number]=1&page[size]=15",
    "prev": "http://localhost/api/v1/posts?page[number]=1&page[size]=15",
    "next": "http://localhost/api/v1/posts?page[number]=3&page[size]=15",
    "last": "http://localhost/api/v1/posts?page[number]=4&page[size]=15"
  },
  "data": [...]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM