-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from getBoolean/feature/pagination
Add Riverpod Pagination Code
- Loading branch information
Showing
26 changed files
with
625 additions
and
71 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "300451adae589accbece3490f4396f10bdf15e6e" | ||
channel: "stable" | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). | ||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-library-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/developing-packages). | ||
--> | ||
|
||
A simple way to implement paginated results using riverpod providers | ||
|
||
## Features | ||
|
||
### Paginated View | ||
|
||
A `StatelessWidget` that can be used to display a paginated list of items. | ||
|
||
```dart | ||
PaginatedView( | ||
itemsProviderBuilder: (int page) => ref.watch(itemsProviderBuilder( | ||
page: page, | ||
)), | ||
invalidateItemsProvider: () => ref.invalidate(itemsProviderBuilder), | ||
invalidateItemPageProvider: (int page) => | ||
ref.invalidate(itemsProviderBuilder( | ||
page: page, | ||
)), | ||
refreshItemPageProvider: (int page) async => | ||
await ref.watch(itemsProviderBuilder( | ||
page: page, | ||
)).future, | ||
itemBuilder: (BuildContext context, T item, int indexInPage) => ..., | ||
loadingItemBuilder: (BuildContext context, int page, int indexInPage) => ..., | ||
errorItemBuilder: (BuildContext context, int page, int indexInPage, Object error, StackTrace stack) => ..., | ||
shrinkWrap: true, | ||
transitionDuration: const Duration(milliseconds: 650), | ||
transitionCurve: Curves.easeInOut, | ||
reverseTransitionCurve: null, | ||
restorationId: null, | ||
) | ||
``` | ||
|
||
### Paginated Result | ||
|
||
Implement a `PaginatedResult` for your API response. This result can then be used | ||
anywhere a `PaginatedResult` is expected, such as with `PaginatedView`. | ||
|
||
### Keep Alive Duration | ||
|
||
Keeps an `autoDispose Provider` alive for a given `Duration` even if | ||
the provider is no longer used. | ||
|
||
```dart | ||
keepAliveDuration<T>( | ||
AutoDisposeRef<T> ref, [ | ||
Duration duration = const Duration(seconds: 30), | ||
]) | ||
``` | ||
|
||
## Resources | ||
|
||
- [Andrea's Pagination article](https://codewithandrea.com/articles/flutter-riverpod-pagination/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library pagination; | ||
|
||
export 'package:pagination_dart/pagination_dart.dart'; | ||
export 'src/paginated_view.dart'; |
Oops, something went wrong.