From 773dc57cb4e65c2b85f5171be31b58e872f06107 Mon Sep 17 00:00:00 2001 From: ishaf Date: Wed, 28 Feb 2024 00:45:39 +0600 Subject: [PATCH 1/3] docs: update demo gif --- README.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7491a4d..2f8787f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Loadmore Data + [![Pub](https://img.shields.io/pub/v/loadmore_data.svg)](https://pub.dartlang.org/packages/loadmore_data) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://opensource.org/licenses/MIT) -[![License](https://img.shields.io/badge/license-MIT-orange.svg)](https://github.com/ionicfirebaseapp/getwidget/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-MIT-orange.svg)](https://github.com/ionicfirebaseapp/getwidget/blob/master/LICENSE) loadmore_data is a flutter package that can handel infinity scroll pagination ## Demo -![loadmore_data](https://www.ishaf.info/load_more.gif "loadmore_data demo") - +![loadmore_data](https://pub-025eba96160d45eb8b4d209ff55bfdc6.r2.dev/load_more.gif "loadmore_data demo") ## Installation 💻 @@ -17,20 +17,20 @@ installed on your machine.** Add `loadmore_data` to your `pubspec.yaml`: -```yaml +``` yaml dependencies: loadmore_data: ``` Install it: -```sh +``` sh flutter packages get ``` ## Example -```dart +``` dart LoadMoreListData( onInit: () async { // call api for initial data and return list of data @@ -57,17 +57,19 @@ LoadMoreListData( }, ), ``` + ## Parameters -| Parameter | Definition | + +| Parameter | Definition | |-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -|`OnInit onInit`| [onInit] is a required argument for the [LoadMoreListData] widget. It takes a function that will return [OnInit] . [OnInit] can be `FutureOr>` This function will call on `initState` of [LoadMoreListData]'s life cycle | -|`OnLoad onLoad`| [onLoad] is a required argument for the [LoadMoreListData] widget. It takes a function that will return [OnLoad] . [OnLoad] can be `FutureOr>` This function will call when the user reached to the end of the list of data | -|`ItemBuilder builder`| builder will [BuildContext] and `itemData` as a single item. and it will expect a widget that will represent a single item | -|`Widget? onInitialLoading`| [onInitialLoading] is a widget that will display until the initial data is loaded | -|`Widget? onLoadMoreLoading`| [onLoadMoreLoading] is a widget at end of the list that will display when waiting for a response on a pagination API request | -|`Widget? onNoData`| [onNoData] is a widget that will have no more data to display | -|`Widget? topWidget`| you can pass an additional widget that will display on top of the list | -|`Widget? bottomWidget`| you can pass an additional widget that will display on the bottom of the list | -|`int? initPage`| [initPage] will take a [int] value representing the initial circle of requests. by default its is `1` | -|`EdgeInsetsGeometry? padding`| padding for [LoadMoreListData] widget | -|`EdgeInsetsGeometry? itemPadding`| padding for [LoadMoreListData] widget's items | +| `OnInit onInit` | [onInit] is a required argument for the [LoadMoreListData] widget. It takes a function that will return [OnInit] . [OnInit] can be `FutureOr>` This function will call on `initState` of [LoadMoreListData]'s life cycle | +| `OnLoad onLoad` | [onLoad] is a required argument for the [LoadMoreListData] widget. It takes a function that will return [OnLoad] . [OnLoad] can be `FutureOr>` This function will call when the user reached to the end of the list of data | +| `ItemBuilder builder` | builder will [BuildContext] and `itemData` as a single item. and it will expect a widget that will represent a single item | +| `Widget? onInitialLoading` | [onInitialLoading] is a widget that will display until the initial data is loaded | +| `Widget? onLoadMoreLoading` | [onLoadMoreLoading] is a widget at end of the list that will display when waiting for a response on a pagination API request | +| `Widget? onNoData` | [onNoData] is a widget that will have no more data to display | +| `Widget? topWidget` | you can pass an additional widget that will display on top of the list | +| `Widget? bottomWidget` | you can pass an additional widget that will display on the bottom of the list | +| `int? initPage` | [initPage] will take a [int] value representing the initial circle of requests. by default its is `1` | +| `EdgeInsetsGeometry? padding` | padding for [LoadMoreListData] widget | +| `EdgeInsetsGeometry? itemPadding` | padding for [LoadMoreListData] widget's items | From afd5ea94c430b941ac3c7573f9095b4fbc928318 Mon Sep 17 00:00:00 2001 From: ishaf Date: Wed, 28 Feb 2024 00:47:00 +0600 Subject: [PATCH 2/3] fix: rebuild widget with didUpdateWidget lifecycle --- lib/src/load_more_data.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/load_more_data.dart b/lib/src/load_more_data.dart index 107c365..81a83ed 100644 --- a/lib/src/load_more_data.dart +++ b/lib/src/load_more_data.dart @@ -126,6 +126,18 @@ class _LoadMoreListDataState extends State> { super.dispose(); } + @override + void didUpdateWidget(covariant LoadMoreListData oldWidget) { + if (oldWidget.onInit != widget.onInit) { + index = widget.initPage != null ? widget.initPage! + 1 : 2; + isInitData = false; + isNoData = false; + initData(); + setState(() {}); + } + super.didUpdateWidget(oldWidget); + } + @override Widget build(BuildContext context) { return ListView( From 370d7f42733767aa7dbb4807301c0b641865827c Mon Sep 17 00:00:00 2001 From: ishaf Date: Wed, 28 Feb 2024 00:47:11 +0600 Subject: [PATCH 3/3] chore: updated version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index d8bb0dc..fef4f4e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: loadmore_data description: loadmore_data is a flutter package that can handel infinity scroll pagination -version: 0.0.1+3 +version: 0.0.2 homepage: https://github.com/ishafiul/loadmore_data repository: https://github.com/ishafiul/loadmore_data