Skip to content

Commit 896cf00

Browse files
author
Kamil Klyta
committed
v2.0.1
1 parent 3265356 commit 896cf00

File tree

6 files changed

+94
-8
lines changed

6 files changed

+94
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 2.0.1
2+
- Added missing *isCanceling* and *isSettling* getters for *IndicatorState* and *IndicatorController* enum.
13
## 2.0.0
24
## Breaking changes
35
- Added `autoRebuild` flag which is by default set to `true`.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ packages:
4242
path: ".."
4343
relative: true
4444
source: path
45-
version: "2.0.0"
45+
version: "2.0.1"
4646
fake_async:
4747
dependency: transitive
4848
description:

lib/src/controller.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,30 @@ class IndicatorController extends ChangeNotifier {
134134

135135
/// Describes current [CustomRefreshIndicator] state
136136
IndicatorState get state => _currentState;
137-
bool get isArmed => _currentState.isArmed;
137+
138+
/// {@macro custom_refresh_indicator.indicator_state.idle}
139+
bool get isIdle => _currentState.isIdle;
140+
141+
/// {@macro custom_refresh_indicator.indicator_state.dragging}
138142
bool get isDragging => _currentState.isDragging;
143+
144+
/// {@macro custom_refresh_indicator.indicator_state.canceling}
145+
bool get isCanceling => _currentState.isCanceling;
146+
147+
/// {@macro custom_refresh_indicator.indicator_state.armed}
148+
bool get isArmed => _currentState.isArmed;
149+
150+
/// {@macro custom_refresh_indicator.indicator_state.settling}
151+
bool get isSettling => _currentState.isSettling;
152+
153+
/// {@macro custom_refresh_indicator.indicator_state.loading}
139154
bool get isLoading => _currentState.isLoading;
155+
156+
/// {@macro custom_refresh_indicator.indicator_state.complete}
140157
bool get isComplete => _currentState.isComplete;
158+
159+
/// {@macro custom_refresh_indicator.indicator_state.finalizing}
141160
bool get isFinalizing => _currentState.isFinalizing;
142-
bool get isIdle => _currentState.isIdle;
143161

144162
bool _shouldStopDrag;
145163

lib/src/data/indicator_state.dart

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,82 @@
11
/// Describes state of CustomRefreshIndicator widget.
22
enum IndicatorState {
3-
///In this state, the indicator is not visible.
4-
///No user action is performed. Value remains at *0.0*.
3+
/// {@template custom_refresh_indicator.indicator_state.idle}
4+
/// In this state, the indicator is not visible.
5+
/// No user action is performed. Value remains at *0.0*.
6+
/// {@endtemplate}
57
idle,
68

9+
/// {@template custom_refresh_indicator.indicator_state.dragging}
710
/// The user starts scrolling/dragging the pointer to refresh.
811
/// Releasing the pointer in this state will not trigger
912
/// the *onRefresh* function. The controller value changes
1013
/// from *0.0* to *1.0*.
14+
/// {@endtemplate}
1115
dragging,
1216

17+
/// {@template custom_refresh_indicator.indicator_state.canceling}
1318
/// The function *onRefresh* **has not been executed**,
1419
/// and the indicator is hidding from its current value
1520
/// that is lower than *1.0* to *0.0*.
21+
/// {@endtemplate}
1622
canceling,
1723

24+
/// {@template custom_refresh_indicator.indicator_state.armed}
1825
/// The user has dragged the pointer further than the distance
1926
/// declared by *containerExtentPercentageToArmed* or *offsetToArmed*
2027
/// (over the value of *1.0*). Releasing the pointer in this state will
2128
/// trigger the *onRefresh* function.
29+
/// {@endtemplate}
2230
armed,
2331

32+
/// {@template custom_refresh_indicator.indicator_state.settling}
2433
/// The user has released the indicator in the armed state.
2534
/// The indicator settles on its target value *1.0*.
35+
/// {@endtemplate}
2636
settling,
2737

38+
/// {@template custom_refresh_indicator.indicator_state.loading}
2839
/// The indicator is in its target value *1.0*.
2940
/// The *onRefresh* function is triggered.
41+
/// {@endtemplate}
3042
loading,
3143

44+
/// {@template custom_refresh_indicator.indicator_state.complete}
3245
/// **OPTIONAL** - Provide `completeStateDuration` argument to enable it.
3346
/// The *onRefresh* callback has completed and the pointer remains
3447
/// at value *1.0* for the specified duration.
48+
/// {@endtemplate}
3549
complete,
3650

51+
/// {@template custom_refresh_indicator.indicator_state.finalizing}
3752
/// The *onRefresh* function **has been executed**, and the indicator
3853
/// hides from the value *1.0* to *0.0*.
54+
/// {@endtemplate}
3955
finalizing,
4056
}
4157

4258
extension IndicatorStateGetters on IndicatorState {
59+
/// {@macro custom_refresh_indicator.indicator_state.idle}
4360
bool get isIdle => this == IndicatorState.idle;
61+
62+
/// {@macro custom_refresh_indicator.indicator_state.dragging}
4463
bool get isDragging => this == IndicatorState.dragging;
45-
bool get isArmed => this == IndicatorState.armed;
46-
bool get isFinalizing => this == IndicatorState.finalizing;
64+
65+
/// {@macro custom_refresh_indicator.indicator_state.canceling}
4766
bool get isCanceling => this == IndicatorState.canceling;
67+
68+
/// {@macro custom_refresh_indicator.indicator_state.armed}
69+
bool get isArmed => this == IndicatorState.armed;
70+
71+
/// {@macro custom_refresh_indicator.indicator_state.settling}
72+
bool get isSettling => this == IndicatorState.settling;
73+
74+
/// {@macro custom_refresh_indicator.indicator_state.loading}
4875
bool get isLoading => this == IndicatorState.loading;
76+
77+
/// {@macro custom_refresh_indicator.indicator_state.complete}
4978
bool get isComplete => this == IndicatorState.complete;
79+
80+
/// {@macro custom_refresh_indicator.indicator_state.finalizing}
81+
bool get isFinalizing => this == IndicatorState.finalizing;
5082
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: custom_refresh_indicator
22
description: Flutter Widget that make it easy to implement custom refresh indicator.
3-
version: 2.0.0
3+
version: 2.0.1
44
repository: https://github.com/gonuit/flutter-custom-refresh-indicator
55
issue_tracker: https://github.com/gonuit/flutter-custom-refresh-indicator/issues
66
homepage: https://github.com/gonuit/flutter-custom-refresh-indicator

test/src/controller_test.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void main() {
3838
expect(controller.isArmed, isFalse);
3939
expect(controller.isLoading, isFalse);
4040
expect(controller.isComplete, isFalse);
41+
expect(controller.isCanceling, isFalse);
42+
expect(controller.isSettling, isFalse);
4143
expect(controller.isRefreshEnabled, isTrue);
4244
expect(controller.isScrollIdle, isTrue);
4345
expect(controller.isScrollingForward, isFalse);
@@ -66,6 +68,8 @@ void main() {
6668
expect(controller.isArmed, isFalse);
6769
expect(controller.isLoading, isFalse);
6870
expect(controller.isComplete, isFalse);
71+
expect(controller.isCanceling, isFalse);
72+
expect(controller.isSettling, isFalse);
6973

7074
controller.setIndicatorState(IndicatorState.dragging);
7175
expect(controller.isIdle, isFalse);
@@ -74,6 +78,8 @@ void main() {
7478
expect(controller.isArmed, isFalse);
7579
expect(controller.isLoading, isFalse);
7680
expect(controller.isComplete, isFalse);
81+
expect(controller.isCanceling, isFalse);
82+
expect(controller.isSettling, isFalse);
7783

7884
controller.setIndicatorState(IndicatorState.finalizing);
7985
expect(controller.isIdle, isFalse);
@@ -82,6 +88,8 @@ void main() {
8288
expect(controller.isArmed, isFalse);
8389
expect(controller.isLoading, isFalse);
8490
expect(controller.isComplete, isFalse);
91+
expect(controller.isCanceling, isFalse);
92+
expect(controller.isSettling, isFalse);
8593

8694
controller.setIndicatorState(IndicatorState.armed);
8795
expect(controller.isIdle, isFalse);
@@ -90,6 +98,8 @@ void main() {
9098
expect(controller.isArmed, isTrue);
9199
expect(controller.isLoading, isFalse);
92100
expect(controller.isComplete, isFalse);
101+
expect(controller.isCanceling, isFalse);
102+
expect(controller.isSettling, isFalse);
93103

94104
controller.setIndicatorState(IndicatorState.loading);
95105
expect(controller.isIdle, isFalse);
@@ -98,6 +108,8 @@ void main() {
98108
expect(controller.isArmed, isFalse);
99109
expect(controller.isLoading, isTrue);
100110
expect(controller.isComplete, isFalse);
111+
expect(controller.isCanceling, isFalse);
112+
expect(controller.isSettling, isFalse);
101113

102114
controller.setIndicatorState(IndicatorState.complete);
103115
expect(controller.isIdle, isFalse);
@@ -106,6 +118,28 @@ void main() {
106118
expect(controller.isArmed, isFalse);
107119
expect(controller.isLoading, isFalse);
108120
expect(controller.isComplete, isTrue);
121+
expect(controller.isCanceling, isFalse);
122+
expect(controller.isSettling, isFalse);
123+
124+
controller.setIndicatorState(IndicatorState.settling);
125+
expect(controller.isIdle, isFalse);
126+
expect(controller.isDragging, isFalse);
127+
expect(controller.isFinalizing, isFalse);
128+
expect(controller.isArmed, isFalse);
129+
expect(controller.isLoading, isFalse);
130+
expect(controller.isComplete, isFalse);
131+
expect(controller.isCanceling, isFalse);
132+
expect(controller.isSettling, isTrue);
133+
134+
controller.setIndicatorState(IndicatorState.canceling);
135+
expect(controller.isIdle, isFalse);
136+
expect(controller.isDragging, isFalse);
137+
expect(controller.isFinalizing, isFalse);
138+
expect(controller.isArmed, isFalse);
139+
expect(controller.isLoading, isFalse);
140+
expect(controller.isComplete, isFalse);
141+
expect(controller.isCanceling, isTrue);
142+
expect(controller.isSettling, isFalse);
109143
});
110144

111145
test("refresh changes correctly and notifies listeners", () {

0 commit comments

Comments
 (0)