Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a3dd5aea
Unverified
Commit
a3dd5aea
authored
Feb 17, 2021
by
xubaolin
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ScrollController.jumpTo zero should not trigger the refresh indicator (#75764)
parent
fe0ceeb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
refresh_indicator.dart
packages/flutter/lib/src/material/refresh_indicator.dart
+5
-1
refresh_indicator_test.dart
packages/flutter/test/material/refresh_indicator_test.dart
+32
-0
No files found.
packages/flutter/lib/src/material/refresh_indicator.dart
View file @
a3dd5aea
...
...
@@ -262,7 +262,11 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
}
bool
_shouldStart
(
ScrollNotification
notification
)
{
return
(
notification
is
ScrollStartNotification
||
(
notification
is
ScrollUpdateNotification
&&
notification
.
dragDetails
!=
null
&&
widget
.
triggerMode
==
RefreshIndicatorTriggerMode
.
anywhere
))
// If the notification.dragDetails is null, this scroll is not triggered by
// user dragging. It may be a result of ScrollController.jumpTo or ballistic scroll.
// In this case, we don't want to trigger the refresh indicator.
return
((
notification
is
ScrollStartNotification
&&
notification
.
dragDetails
!=
null
)
||
(
notification
is
ScrollUpdateNotification
&&
notification
.
dragDetails
!=
null
&&
widget
.
triggerMode
==
RefreshIndicatorTriggerMode
.
anywhere
))
&&
notification
.
metrics
.
extentBefore
==
0.0
&&
_mode
==
null
&&
_start
(
notification
.
metrics
.
axisDirection
);
...
...
packages/flutter/test/material/refresh_indicator_test.dart
View file @
a3dd5aea
...
...
@@ -677,6 +677,38 @@ void main() {
expect
(
find
.
byType
(
RefreshProgressIndicator
),
findsNothing
);
});
testWidgets
(
'ScrollController.jumpTo should not trigger the refresh indicator'
,
(
WidgetTester
tester
)
async
{
refreshCalled
=
false
;
final
ScrollController
scrollController
=
ScrollController
(
initialScrollOffset:
500.0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
RefreshIndicator
(
onRefresh:
refresh
,
child:
ListView
(
controller:
scrollController
,
physics:
const
AlwaysScrollableScrollPhysics
(),
children:
const
<
Widget
>[
SizedBox
(
height:
800.0
,
child:
Text
(
'X'
),
),
SizedBox
(
height:
800.0
,
child:
Text
(
'Y'
),
),
],
),
),
),
);
scrollController
.
jumpTo
(
0.0
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator settle animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator hide animation
expect
(
refreshCalled
,
false
);
});
testWidgets
(
'RefreshIndicator.color can be updated at runtime'
,
(
WidgetTester
tester
)
async
{
refreshCalled
=
false
;
Color
refreshIndicatorColor
=
Colors
.
green
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment