Last updated:
0 purchases
http pagination
Http pagination #
Http headers pagination parser
Inspired by js lib parse-link-header
Features #
Parses a link header (web links) and returns pagination data
Works both with pages and cursor pagination
Getting started #
dependencies:
http_pagination: ^0.2.2
copied to clipboard
Usage #
Pages pagination
import 'package:http_pagination/http_pagination.dart';
final headers = {
'link': [
'<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next", ' +
'<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev", ' +
'<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"'
],
};
final pagination = PagesPagination.fromHeaders(headers);
print(pagination); // PagesPagination(first: null, next: 3, prev: 1, last: 5)
copied to clipboard
Cursor pagination
import 'package:http_pagination/http_pagination.dart';
final headers = {
'link': [
'<http://example.com/items?cursor=a>; rel="first", ' +
'<http://example.com/items?cursor=b>; rel="next", ' +
'<http://example.com/items?cursor=c>; rel="prev", ' +
'<http://example.com/items?cursor=d>; rel="last"',
],
};
final pagination = CursorPagination.fromHeaders(headers);
print(pagination); // CursorPagination(first: a, next: b, prev: c, last: d)
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.