pagination_core 1.0.1
pagination_core: ^1.0.1 copied to clipboard
A simple and reusable pagination handler for any state management solution in Flutter.
pagination_core #
pagination_core is a Flutter/Dart package designed to simplify pagination management in applications. This package makes it easy to load data progressively as the user scrolls through the list, reducing memory load and optimizing performance in apps that handle large amounts of data.
Installation #
Add pagination_core to your pubspec.yaml file:
dependencies:
pagination_core: ^1.0.0
Then, run the following command to install the dependency:
flutter pub get
π οΈ Basic Usage
Hereβs an example usage with mock data :
final paginator = Paginator<Post>(
fetchFunction: (params) async {
// Simule une API
return {
'data': [...],
'meta': {'currentPage': 1, 'lastPage': 5},
};
},
parseItems: (data) => (data as List).map((e) => Post.fromJson(e)).toList(),
parseMeta: (meta) => Meta.fromJson(meta),
);
Then, use paginator.fetch() to load the initial data and paginator.loadNextPage() to load the next page.
π Full Example
A complete example is available in the example folder to guide you through the integration into your project.
π‘ Contribution
Contributions are welcome! If you find a bug or want to add a feature, feel free to submit a pull request.