Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/EdsonBueno/infinite_scroll_pagination
Flutter package to help you lazily load and display pages of items as the user scrolls down your screen.
https://github.com/EdsonBueno/infinite_scroll_pagination
endless-scroll endless-scrolling endless-scrolling-flutter flutter infinite-scroll infinite-scrolling load-more load-more-flutter pagination
Last synced: about 2 months ago
JSON representation
Flutter package to help you lazily load and display pages of items as the user scrolls down your screen.
- Host: GitHub
- URL: https://github.com/EdsonBueno/infinite_scroll_pagination
- Owner: EdsonBueno
- License: mit
- Created: 2020-08-22T17:27:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T13:50:50.000Z (about 2 months ago)
- Last Synced: 2024-10-28T15:21:05.495Z (about 2 months ago)
- Topics: endless-scroll, endless-scrolling, endless-scrolling-flutter, flutter, infinite-scroll, infinite-scrolling, load-more, load-more-flutter, pagination
- Language: Dart
- Homepage: https://pub.dev/packages/infinite_scroll_pagination
- Size: 4.1 MB
- Stars: 629
- Watchers: 5
- Forks: 214
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Chosen as a Flutter Favorite by the Flutter Ecosystem Committee
---
# Infinite Scroll Pagination
Unopinionated, extensible and highly customizable package to help you lazily load and display small chunks of items as the user scrolls down the screen – known as infinite scrolling pagination, endless scrolling pagination, auto-pagination, lazy loading pagination, progressive loading pagination, etc.
Designed to feel like part of the Flutter framework.
## Tutorial
[By raywenderlich.com (step-by-step, hands-on, in-depth, and illustrated)](https://www.raywenderlich.com/14214369-infinite-scrolling-pagination-in-flutter).
## Usage
```dart
class BeerListView extends StatefulWidget {
@override
_BeerListViewState createState() => _BeerListViewState();
}class _BeerListViewState extends State {
static const _pageSize = 20;final PagingController _pagingController =
PagingController(firstPageKey: 0);@override
void initState() {
super.initState();
_pagingController.addPageRequestListener((pageKey) {
_fetchPage(pageKey);
});
}Future _fetchPage(int pageKey) async {
try {
final newItems = await RemoteApi.getBeerList(pageKey, _pageSize);
final isLastPage = newItems.length < _pageSize;
if (isLastPage) {
_pagingController.appendLastPage(newItems);
} else {
final nextPageKey = pageKey + newItems.length;
_pagingController.appendPage(newItems, nextPageKey);
}
} catch (error) {
_pagingController.error = error;
}
}@override
Widget build(BuildContext context) =>
// Don't worry about displaying progress or error indicators on screen; the
// package takes care of that. If you want to customize them, use the
// [PagedChildBuilderDelegate] properties.
PagedListView(
pagingController: _pagingController,
builderDelegate: PagedChildBuilderDelegate(
itemBuilder: (context, item, index) => BeerListItem(
beer: item,
),
),
);@override
void dispose() {
_pagingController.dispose();
super.dispose();
}
}
```For more usage examples, please take a look at our [cookbook](https://pub.dev/packages/infinite_scroll_pagination/example) or check out the [example project](https://github.com/EdsonBueno/infinite_scroll_pagination/tree/master/example).
## Features
- **Architecture-agnostic**: Works with any state management approach, from [setState](https://flutter.dev/docs/development/data-and-backend/state-mgmt/options#setstate) to [BLoC](https://flutter.dev/docs/development/data-and-backend/state-mgmt/options#bloc--rx). Not even [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html) usage is assumed.
- **Layout-agnostic**: Out-of-the-box widgets corresponding to [GridView](https://pub.dev/documentation/infinite_scroll_pagination/latest/infinite_scroll_pagination/PagedGridView-class.html), [SliverGrid](https://pub.dev/documentation/infinite_scroll_pagination/latest/infinite_scroll_pagination/PagedSliverGrid-class.html), [ListView](https://pub.dev/documentation/infinite_scroll_pagination/latest/infinite_scroll_pagination/PagedListView-class.html) and [SliverList](https://pub.dev/documentation/infinite_scroll_pagination/latest/infinite_scroll_pagination/PagedSliverList-class.html) – including `.separated` constructors. Not enough? You can [easily create a custom layout](https://pub.dev/packages/infinite_scroll_pagination/example#custom-layout).
- **API-agnostic**: By letting you in complete charge of your API calls, **Infinite Scroll Pagination** works with [any pagination strategy](https://nordicapis.com/everything-you-need-to-know-about-api-pagination/).
- **Highly customizable**: [You can change everything](https://pub.dev/packages/infinite_scroll_pagination/example#customizing-indicators). Provide your own progress, error and empty list indicators. Too lazy to change? The defaults will cover you.
- **Extensible**: Seamless integration with [pull-to-refresh](https://pub.dev/packages/infinite_scroll_pagination/example#pull-to-refresh), [searching, filtering and sorting](https://pub.dev/packages/infinite_scroll_pagination/example#searchingfilteringsorting).
- **Listen to state changes**: In addition to displaying widgets to inform the current status, such as progress and error indicators, you can also [use a listener](https://pub.dev/packages/infinite_scroll_pagination/example#listening-to-status-changes) to display dialogs/snackbars/toasts or execute any other action.
## API Overview