Skip to content

Commit 6544819

Browse files
committed
format code
1 parent 195af8b commit 6544819

15 files changed

+135
-145
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 2.0.0
2+
### Breaking Changes:
3+
* Remove onOffsetChange in SmartRefresher,autoLoad in RefreshConfiguration,scrollController in RefreshController
4+
* add argument to onTwoLevel(callback when closed)
5+
6+
### features
7+
* migrate null-safety
8+
* add needCallback in requestRefresh and requestLoading for avoiding the callback of onRefresh or onLoading
9+
10+
### Bug fix
11+
* In NestedScrollView+ClampingScrollPhysics(Android ScrollBehaviour),header can be seen when fling to top.
12+
* unMounted widget used crash error when fast rebuild in requestRefresh
13+
14+
### Other
15+
* Add assert to avoid invalid usage
16+
17+
18+
119
## 1.6.5
220
* fix check full page logic.
321
* fix crash "locking up a deactive widget is unsafe".

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios.
1414
If you are Chinese,click here([中文文档](https://github.com/peng8350/flutter_pulltorefresh/blob/master/README_CN.md))
1515

16-
[Download Demo(Android)](demo.apk):
1716

18-
![qrCode](arts/qr_code.png)
1917

2018
## Features
2119
* pull up load and pull down refresh

README_CN.md

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
## 介绍
1313
一个提供上拉加载和下拉刷新的组件,同时支持Android和Ios<br>
1414

15-
[下载Demo(Android)](demo.apk):
16-
17-
![二维码](arts/qr_code.png)
1815

1916

2017
## 特性

arts/qr_code.png

-5.76 KB
Binary file not shown.

demo.apk

-17.4 MB
Binary file not shown.

example/lib/other/refresh_recordable_listview.dart

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class RefreshReorderableListView extends StatefulWidget {
5858

5959
final Function onRefresh, onLoading;
6060

61-
6261
final RefreshController refreshController;
6362

6463
/// Creates a reorderable list.

example/lib/ui/example/useStage/twolevel_refresh.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class _TwoLevelExampleState extends State<TwoLevelExample> {
130130
_refreshController1.refreshCompleted();
131131
},
132132
onTwoLevel: (bool isOpen) {
133-
print("twoLevel opening:"+isOpen.toString());
133+
print("twoLevel opening:" + isOpen.toString());
134134
},
135135
);
136136
},
@@ -164,15 +164,15 @@ class _TwoLevelExampleState extends State<TwoLevelExample> {
164164
_refreshController2.refreshCompleted();
165165
},
166166
onTwoLevel: (bool isOpen) {
167-
if(isOpen){
167+
if (isOpen) {
168168
print("Asd");
169169
_refreshController2.position.hold(() {});
170170
Navigator.of(context)
171171
.push(MaterialPageRoute(
172-
builder: (c) => Scaffold(
173-
appBar: AppBar(),
174-
body: Text("二楼刷新"),
175-
)))
172+
builder: (c) => Scaffold(
173+
appBar: AppBar(),
174+
body: Text("二楼刷新"),
175+
)))
176176
.whenComplete(() {
177177
_refreshController2.twoLevelComplete(
178178
duration: Duration(microseconds: 1));

example/lib/ui/test/Test3.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class Test3State extends State<Test3> with TickerProviderStateMixin {
2525
children: <Widget>[
2626
FlatButton(
2727
onPressed: () {
28-
29-
_refreshController.requestRefresh(needCallback: false).then((value) async {
28+
_refreshController
29+
.requestRefresh(needCallback: false)
30+
.then((value) async {
3031
print("requestRefresh");
3132
await Future.delayed(const Duration(milliseconds: 5000));
3233
_refreshController.refreshCompleted();
@@ -35,7 +36,9 @@ class Test3State extends State<Test3> with TickerProviderStateMixin {
3536
child: Text("请求刷新")),
3637
FlatButton(
3738
onPressed: () {
38-
_refreshController.requestLoading(needCallback: false).then((value) async {
39+
_refreshController
40+
.requestLoading(needCallback: false)
41+
.then((value) async {
3942
print("requestLoading");
4043
await Future.delayed(const Duration(milliseconds: 5000));
4144
_refreshController.loadComplete();

lib/src/indicator/material_indicator.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ class _WaterDropMaterialHeaderState extends _MaterialClassicHeaderState {
334334
),
335335
height: 100.0,
336336
);
337-
}}
337+
}
338+
}
338339

339340
class _WaterPainter extends CustomPainter {
340341
final Color? color;
341342
final Animation<Offset>? listener;
342343

343-
344344
Offset get offset => listener!.value;
345345
final double? ratio;
346346

lib/src/internals/indicator_wrap.dart

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Author: Jpeng
2+
Author: JPeng
33
44
createTime:2018-05-14 15:39
55
*/
@@ -247,8 +247,8 @@ abstract class RefreshIndicatorState<T extends RefreshIndicator>
247247
if (!mounted) return;
248248
floating = false;
249249
if (mode == RefreshStatus.completed || mode == RefreshStatus.failed) {
250-
refresherState
251-
!.setCanDrag(configuration!.enableScrollWhenRefreshCompleted);
250+
refresherState!
251+
.setCanDrag(configuration!.enableScrollWhenRefreshCompleted);
252252
}
253253
update();
254254
/*
@@ -576,8 +576,6 @@ mixin IndicatorStateMixin<T extends StatefulWidget, V> on State<T> {
576576
RefreshConfiguration? configuration;
577577
SmartRefresherState? refresherState;
578578

579-
580-
581579
bool _floating = false;
582580

583581
set floating(floating) => _floating = floating;
@@ -592,7 +590,7 @@ mixin IndicatorStateMixin<T extends StatefulWidget, V> on State<T> {
592590

593591
ScrollActivity? get activity => _position!.activity;
594592

595-
// it doesn't support get the ScrollController as the listener, because it will cause "multiple scrollview use one ScollController"
593+
// it doesn't support get the ScrollController as the listener, because it will cause "multiple scrollview use one ScrollController"
596594
// error,only replace the ScrollPosition to listen the offset
597595
ScrollPosition? _position;
598596

lib/src/internals/refresh_physics.dart

+8-5
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,15 @@ class RefreshPhysics extends ScrollPhysics {
192192
double topExtra = 0.0;
193193
double? bottomExtra = 0.0;
194194
if (enablePullDown) {
195-
final RenderSliverRefresh sliverHeader = viewportRender!.firstChild as RenderSliverRefresh;
195+
final RenderSliverRefresh sliverHeader =
196+
viewportRender!.firstChild as RenderSliverRefresh;
196197
topExtra = sliverHeader.hasLayoutExtent
197198
? 0.0
198199
: sliverHeader.refreshIndicatorLayoutExtent;
199200
}
200201
if (enablePullUp) {
201-
final RenderSliverLoading? sliverFooter = viewportRender!.lastChild as RenderSliverLoading?;
202+
final RenderSliverLoading? sliverFooter =
203+
viewportRender!.lastChild as RenderSliverLoading?;
202204
bottomExtra = (!notFull && sliverFooter!.geometry!.scrollExtent != 0) ||
203205
(notFull &&
204206
controller!.footerStatus == LoadStatus.noMore &&
@@ -291,9 +293,10 @@ class RefreshPhysics extends ScrollPhysics {
291293
velocity: velocity * 0.91,
292294
// TODO(abarth): We should move this constant closer to the drag end.
293295
leadingExtent: position.minScrollExtent,
294-
trailingExtent: controller!.headerMode!.value == RefreshStatus.twoLeveling
295-
? 0.0
296-
: position.maxScrollExtent,
296+
trailingExtent:
297+
controller!.headerMode!.value == RefreshStatus.twoLeveling
298+
? 0.0
299+
: position.maxScrollExtent,
297300
tolerance: tolerance,
298301
);
299302
}

0 commit comments

Comments
 (0)