Skip to content

Commit 11f80a2

Browse files
committed
可设置禁止下拉刷新
1 parent df810f4 commit 11f80a2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/Refresh.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class RefreshLayout extends StatefulWidget {
8989
const RefreshLayout({
9090
Key key,
9191
@required this.child,
92+
this.canrefresh: true,
9293
this.canloading: true,
9394
this.displacement: 20.0,
9495
@required this.onRefresh,
@@ -135,6 +136,8 @@ class RefreshLayout extends StatefulWidget {
135136
final ScrollNotificationPredicate notificationPredicate;
136137

137138
final bool canloading;
139+
final bool canrefresh;
140+
138141
// void dissmiss() {
139142
// if(state!=null)
140143
// state._dismiss(_RefreshLayoutMode.canceled);
@@ -271,7 +274,8 @@ class RefreshLayoutState extends State<RefreshLayout>
271274
else if (notification is ScrollEndNotification) {
272275
switch (_mode) {
273276
case _RefreshLayoutMode.armed:
274-
_show();
277+
if (widget.canrefresh)
278+
_show();
275279
break;
276280
case _RefreshLayoutMode.drag:
277281
_dismiss(_RefreshLayoutMode.canceled);
@@ -481,7 +485,8 @@ class RefreshLayoutState extends State<RefreshLayout>
481485
alignment: _isIndicatorAtTop
482486
? Alignment.topCenter
483487
: Alignment.bottomCenter,
484-
child: _isIndicatorAtTop ? new ScaleTransition(
488+
child: _isIndicatorAtTop ? (widget.canrefresh
489+
? new ScaleTransition(
485490
scale: _scaleFactor,
486491
child: new AnimatedBuilder(
487492
animation: _positionController,
@@ -493,7 +498,8 @@ class RefreshLayoutState extends State<RefreshLayout>
493498
);
494499
},
495500
),
496-
) : new AnimatedBuilder(
501+
)
502+
: null) : new AnimatedBuilder(
497503
animation: _positionController,
498504
builder: (BuildContext context, Widget child) {
499505
return new Container(decoration: new BoxDecoration(

0 commit comments

Comments
 (0)