[英]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我从 API 中获取数据,如演示:- {draw: 0, records Total: 210, records Filtered: 210, data: [,...], input: []} data: [,...] draw: 0 input: [] records已过滤:210 条记录总计:210
i want to apply paggination on API data(grid view or list view)how can i do that ?我想对 API 数据(网格视图或列表视图)应用分页,我该怎么做?
Your json structure needs to look like this to apply pagination with ease.您的 json 结构需要看起来像这样才能轻松应用分页。 Use
current page
, next page
and last page
to determine the next, current and remaining pages.使用
current page
、 next page
和last page
来确定下一页、当前页和剩余页。
You can directly use the next
link to get the data of the next page.可以直接使用
next
链接获取next
的数据。
{
"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": [...]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.