https://github.com/frezyx/http_pagination
Parses a link header (web links) and returns pagination data
https://github.com/frezyx/http_pagination
dart dart-package dart-parser dartlang dio flutter http pagination pagination-functionality pagination-library pagination-links
Last synced: about 1 month ago
JSON representation
Parses a link header (web links) and returns pagination data
- Host: GitHub
- URL: https://github.com/frezyx/http_pagination
- Owner: Frezyx
- License: mit
- Created: 2023-04-19T11:40:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-09T16:02:57.000Z (over 2 years ago)
- Last Synced: 2025-04-23T02:38:17.488Z (6 months ago)
- Topics: dart, dart-package, dart-parser, dartlang, dio, flutter, http, pagination, pagination-functionality, pagination-library, pagination-links
- Language: Dart
- Homepage: https://pub.dev/packages/http_pagination
- Size: 23.4 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Http pagination
Http headers pagination parser
Inspired by js lib [parse-link-header](https://github.com/thlorenz/parse-link-header)## Features
Parses a link header [(web links)](https://datatracker.ietf.org/doc/html/rfc5988) and returns pagination data
Works both with pages and cursor pagination## Getting started
```yaml
dependencies:
http_pagination: ^0.2.2
```## Usage
Pages pagination
```dart
import 'package:http_pagination/http_pagination.dart';final headers = {
'link': [
'; rel="next", ' +
'; rel="prev", ' +
'; rel="last"'
],
};
final pagination = PagesPagination.fromHeaders(headers);
print(pagination); // PagesPagination(first: null, next: 3, prev: 1, last: 5)
```Cursor pagination
```dart
import 'package:http_pagination/http_pagination.dart';final headers = {
'link': [
'; rel="first", ' +
'; rel="next", ' +
'; rel="prev", ' +
'; rel="last"',
],
};final pagination = CursorPagination.fromHeaders(headers);
print(pagination); // CursorPagination(first: a, next: b, prev: c, last: d)
```