Skip to content

Commit bad3c7d

Browse files
committed
updated code docs and readme to include version 1.0.1
1 parent 55f305c commit bad3c7d

File tree

7 files changed

+59
-47
lines changed

7 files changed

+59
-47
lines changed

AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the gamma_smart_pagination flutter package. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Gamma Tech Ltd. <https://gammatech.mk>
7+
Zoran Conevski <zoran.conevski@gammatech.mk>
8+
Darko Sarev <darko.sarev@gammatech.mk>

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.1
2+
* Updated code docs
3+
* Internal / non-public facing method names updated
4+
* Updated README
5+
16
## 1.0.0
27
* Breaking changes:
38
- `GammaSmartController` is now `GammaController`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Flutter package for implementing infinite scroll pagination, with support for pu
2626

2727
## Installation
2828

29-
Add `gamma_smart_pagination: ^0.0.1` to your `pubspec.yaml` dependencies. And import it:
29+
Add `gamma_smart_pagination: ^1.0.1` to your `pubspec.yaml` dependencies. And import it:
3030

3131
```dart
3232
import 'package:gamma_smart_pagination/gamma_smart_pagination.dart';

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ packages:
257257
path: ".."
258258
relative: true
259259
source: path
260-
version: "1.0.0"
260+
version: "1.0.1"
261261
glob:
262262
dependency: transitive
263263
description:

lib/src/controller/gamma_controller.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class GammaController extends ChangeNotifier {
1515
_status = const GammaControllerStatus.idle();
1616
}
1717

18-
/// [attachListener] method to add a listener to the controller.
18+
/// add a listener to the controller.
1919
void attachListener(VoidCallback listener) {
2020
_listeners.add(listener);
2121
}
2222

23-
/// [detachListener] method to remove a listener from the controller.
23+
/// remove a listener from the controller.
2424
/// @Params: [listener] is the listener to be removed.
2525
/// If no listener is passed, all listeners will be removed.
2626
void detachListener({VoidCallback? listener}) {
@@ -31,7 +31,7 @@ class GammaController extends ChangeNotifier {
3131
}
3232
}
3333

34-
/// [listeners] getter for the controller listeners.
34+
/// getter for the controller listeners.
3535
List<VoidCallback> get listeners => _listeners;
3636

3737
/// Whether any [Listener] objects have attached themselves to the
@@ -41,66 +41,66 @@ class GammaController extends ChangeNotifier {
4141
/// must not be called.
4242
bool get hasClients => _listeners.isNotEmpty;
4343

44-
/// [GammaControllerStatus] getter for the controller status.
44+
/// getter for the controller status.
4545
GammaControllerStatus get status => _status;
4646

47-
/// [statusString] getter for the controller status as a string.
47+
/// getter for the controller status as a string.
4848
String get statusString => _status.toString();
4949

50-
/// [setIdle] method to set the controller status to idle.
50+
/// set the controller status to idle.
5151
/// Use this method when the widget is first rendered.
5252
/// And also it can be used after the first load of data is completed.
5353
void setIdle() {
5454
_status = const GammaControllerStatus.idle();
5555
notifyListeners();
5656
}
5757

58-
/// [setLoading] method to set the controller status to loading.
58+
/// set the controller status to loading.
5959
/// Use this method when the widget is loading more data.
6060
void setLoading() {
6161
_status = const GammaControllerStatus.loading();
6262
notifyListeners();
6363
}
6464

65-
/// [setLoadingCompleted] method to set the controller status to loadingCompleted.
65+
/// set the controller status to loadingCompleted.
6666
/// Use this method when the widget is done loading more data.
6767
/// But there is still more data to load.
6868
void setLoadingCompleted() {
6969
_status = const GammaControllerStatus.loadingCompleted();
7070
notifyListeners();
7171
}
7272

73-
/// [setLoadingFailed] method to set the controller status to loadingFailed.
73+
/// set the controller status to loadingFailed.
7474
/// Use this method when the widget failed to load more data.
7575
/// @Params: [errorMessage] is the error message that will be displayed in the footer.
7676
void setLoadingFailed({String? errorMessage}) {
7777
_status = GammaControllerStatus.loadingFailed(errorMessage: errorMessage);
7878
notifyListeners();
7979
}
8080

81-
/// [setNoMoreData] method to set the controller status to noMoreData.
81+
/// set the controller status to noMoreData.
8282
/// Use this method when the widget has loaded all the data.
8383
/// AND there is no more data to load.
8484
void setNoMoreData() {
8585
_status = const GammaControllerStatus.noMoreData();
8686
notifyListeners();
8787
}
8888

89-
/// [setRefreshFailed] method to set the controller status to refreshingFailed.
89+
/// set the controller status to refreshingFailed.
9090
/// Use this method when the widget failed to refresh the data.
9191
void setRefreshFailed() {
9292
_status = const GammaControllerStatus.refreshingFailed();
9393
notifyListeners();
9494
}
9595

96-
/// [setRefreshing] method to set the controller status to refreshing.
96+
/// set the controller status to refreshing.
9797
/// Use this method when the widget is refreshing the data.
9898
void setRefreshing() {
9999
_status = const GammaControllerStatus.refreshing();
100100
notifyListeners();
101101
}
102102

103-
/// [setRefreshingCompleted] method to set the controller status to refreshingCompleted.
103+
/// set the controller status to refreshingCompleted.
104104
/// Use this method when the widget is done refreshing the data.
105105
void setRefreshingCompleted() {
106106
_status = const GammaControllerStatus.refreshingCompleted();

lib/src/widget/gamma_smart_pagination.dart

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,48 @@ import 'package:flutter/material.dart';
22
import '../../gamma_smart_pagination.dart';
33
import '../helpers/extensions.dart';
44

5-
/// [GammaSmartPagination] is a wrapper widget for scrollable widgets that enables
5+
/// Wrapper widget for scrollable widgets that enables
66
/// pull to refresh and infinite scrolling pagination.
77
class GammaSmartPagination extends StatefulWidget {
8-
/// [GammaController] that will be used to control the status of the pagination.
8+
/// Controls for the status of the pagination.
99
final GammaController gammaSmartController;
1010

11-
/// [ScrollController] that will be used to control the scroll position of the list internally.
11+
/// Controls the scroll position of the list internally.
1212
final ScrollController scrollController;
1313

14-
/// [onLoadMore] is the callback that will be called when the user scrolls to the bottom of the list.
14+
/// Callback that will be called when the user scrolls to the bottom of the list.
1515
final Future<void> Function()? onLoadMore;
1616

17-
/// [onRefresh] is the callback that will be called when the user pulls down the list.
17+
/// Callback that will be called when the user pulls down the list.
1818
final Future<void> Function()? onRefresh;
1919

20-
/// [@required][child] is the scrollable child widget that will be wrapped by the GammaSmartPagination widget.
20+
/// Scrollable child widget that will be wrapped by the GammaSmartPagination widget.
21+
/// It must have physics set to [NeverScrollableScrollPhysics] and shrinkWrap set to true.
2122
final Widget child;
2223

23-
/// [@required][itemCount] is the number of items in the list.
24+
/// Number of items in the list.
2425
final int itemCount;
2526

26-
/// [noInitialDataWidget] is the widget that will be displayed when the list is empty.
27+
/// Widget that will be displayed when the list is empty.
2728
final Widget? noInitialDataWidget;
2829

29-
/// [noMoreDataWidget] is the widget that will be displayed when the list has loaded all the data.
30+
/// Widget that will be displayed when the list has loaded all the data.
3031
final Widget? noMoreDataWidget;
3132

32-
/// [loadingFailedWidget] is the widget that will be displayed when the list failed to load more data.
33+
/// Widget that will be displayed when the list failed to load more data.
3334
final Widget? loadingFailedWidget;
3435

35-
/// [refreshFailedWidget] is the widget that will be displayed when the list failed to refresh.
36+
/// Widget that will be displayed when the list failed to refresh.
3637
final Widget? refreshFailedWidget;
3738

38-
/// [loadingIndicator] is the widget that will be displayed when the list is loading more data.
39+
/// Widget that will be displayed when the list is loading more data.
3940
final Widget? loadingIndicator;
4041

41-
/// [enableLogging] is a boolean that will enable logging when set to true.
42+
/// Enable logging when set to true.
4243
final bool enableLogging;
4344

44-
/// [GammaSmartPagination] is a 2 in 1 widget that acts as a wrapper for scrollable widgets.
45-
/// It enables pull to refresh and infinite scrolling pagination.
45+
/// Wrapper for scrollable widgets that enables
46+
/// pull to refresh and infinite scrolling pagination.
4647
///
4748
/// Typically used as wrapper for [ListView], [GridView].
4849
///
@@ -71,13 +72,13 @@ class GammaSmartPagination extends StatefulWidget {
7172
}
7273

7374
class _GammaSmartPaginationState extends State<GammaSmartPagination> {
74-
/// [GammaController] that will be used to control the status of the pagination.
75+
/// Controls the status of the pagination.
7576
GammaController get _customController => widget.gammaSmartController;
7677

77-
/// [ScrollController] that will be used to control the scroll position of the list internally.
78+
/// Controls the scroll position of the list internally.
7879
ScrollController get _scrollController => widget.scrollController;
7980

80-
/// [sensitivityFactor] is the factor that will be used to determine if the user has reached the bottom of the list.
81+
/// factor to determine if the user has reached the bottom of the list.
8182
static const double _sensitivityFactor = 200.0;
8283

8384
final wipedGrayTextColorStyle = TextStyle(color: Colors.grey.shade400);
@@ -97,32 +98,33 @@ class _GammaSmartPaginationState extends State<GammaSmartPagination> {
9798

9899
@override
99100
void initState() {
100-
_scrollController.addListener(onBottomReached);
101+
_scrollController.addListener(_onBottomReached);
101102
super.initState();
102103
}
103104

104-
/// [onBottomReached] is called when the user scrolls to the bottom of the list.
105-
void onBottomReached() {
105+
/// Callback when the user scrolls to the bottom of the list.
106+
void _onBottomReached() {
106107
final maxScroll = _scrollController.position.maxScrollExtent;
107108
final currentScroll = _scrollController.position.pixels;
108109
if (currentScroll >= (maxScroll - _sensitivityFactor)) {
109110
if (_customController.shouldLoadMore && currentScroll > 0) {
110111
_logLoadMoreCalled();
111-
onLoadMore();
112+
_onLoadMore();
112113
}
113114
}
114115
}
115116

116-
/// [onLoadMore] is called when the user scrolls to the bottom of the list.
117-
Future<void> onLoadMore() async {
117+
/// Callback when the user scrolls to the bottom of the list.
118+
Future<void> _onLoadMore() async {
118119
_customController.setLoading();
119120
await widget.onLoadMore?.call();
120121
}
121122

122-
/// [onRefresh] is called when the user pulls down the list.
123-
Future<void> onRefresh() async {
123+
/// Called when the user pulls down the list.
124+
Future<void> _onRefresh() async {
125+
_logRefreshCalled();
124126
_customController.setRefreshing();
125-
await widget.onRefresh?.call();
127+
return await widget.onRefresh?.call();
126128
}
127129

128130
@override
@@ -137,10 +139,7 @@ class _GammaSmartPaginationState extends State<GammaSmartPagination> {
137139

138140
RefreshIndicator _buildDataWidget() {
139141
return RefreshIndicator(
140-
onRefresh: () async {
141-
_logRefreshCalled();
142-
return widget.onRefresh?.call();
143-
},
142+
onRefresh: () async => _onRefresh(),
144143
child: SingleChildScrollView(
145144
controller: _scrollController,
146145
physics: const AlwaysScrollableScrollPhysics(),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: gamma_smart_pagination
22
description: Flutter package for infinite scrolling pagination, which supports pull down to refresh and pull up to load more.
3-
version: 1.0.0
3+
version: 1.0.1
44
repository: https://github.com/GammaTechMK/gamma_smart_pagination
55

66
environment:

0 commit comments

Comments
 (0)