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
8817c0d2
Unverified
Commit
8817c0d2
authored
Dec 03, 2020
by
xubaolin
Committed by
GitHub
Dec 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RefreshIndicator can be shown when dragging from non-zero scroll position (#71303)
parent
4e85a67f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
3 deletions
+74
-3
overscroll_demo.dart
...ts/flutter_gallery/lib/demo/material/overscroll_demo.dart
+3
-1
refresh_indicator.dart
packages/flutter/lib/src/material/refresh_indicator.dart
+2
-1
refresh_indicator_test.dart
packages/flutter/test/material/refresh_indicator_test.dart
+69
-1
No files found.
dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart
View file @
8817c0d2
...
...
@@ -27,8 +27,10 @@ class OverscrollDemoState extends State<OverscrollDemo> {
Future
<
void
>
_handleRefresh
()
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
();
}
);
Timer
(
const
Duration
(
seconds:
3
),
()
=>
completer
.
complete
()
);
return
completer
.
future
.
then
((
_
)
{
if
(!
mounted
)
return
;
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
const
Text
(
'Refresh complete'
),
action:
SnackBarAction
(
...
...
packages/flutter/lib/src/material/refresh_indicator.dart
View file @
8817c0d2
...
...
@@ -218,7 +218,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
if
(!
widget
.
notificationPredicate
(
notification
))
return
false
;
if
(
notification
is
ScrollStartNotification
&&
notification
.
metrics
.
extentBefore
==
0.0
&&
if
((
notification
is
ScrollStartNotification
||
notification
is
ScrollUpdateNotification
)
&&
notification
.
metrics
.
extentBefore
==
0.0
&&
_mode
==
null
&&
_start
(
notification
.
metrics
.
axisDirection
))
{
setState
(()
{
_mode
=
_RefreshIndicatorMode
.
drag
;
...
...
packages/flutter/test/material/refresh_indicator_test.dart
View file @
8817c0d2
...
...
@@ -88,7 +88,6 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator hide animation
expect
(
refreshCalled
,
false
);
await
tester
.
fling
(
find
.
text
(
'A'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
// vertical fling
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
...
...
@@ -501,4 +500,73 @@ void main() {
4.0
,
);
});
testWidgets
(
'Top RefreshIndicator showed when dragging from non-zero scroll position'
,
(
WidgetTester
tester
)
async
{
refreshCalled
=
false
;
final
ScrollController
scrollController
=
ScrollController
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
RefreshIndicator
(
onRefresh:
holdRefresh
,
child:
ListView
(
controller:
scrollController
,
physics:
const
AlwaysScrollableScrollPhysics
(),
children:
const
<
Widget
>[
SizedBox
(
height:
200.0
,
child:
Text
(
'X'
),
),
SizedBox
(
height:
800.0
,
child:
Text
(
'Y'
),
),
],
),
),
),
);
scrollController
.
jumpTo
(
50.0
);
await
tester
.
fling
(
find
.
text
(
'X'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator settle animation
expect
(
tester
.
getCenter
(
find
.
byType
(
RefreshProgressIndicator
)).
dy
,
lessThan
(
300.0
));
});
testWidgets
(
'Bottom RefreshIndicator showed when dragging from non-zero scroll position'
,
(
WidgetTester
tester
)
async
{
refreshCalled
=
false
;
final
ScrollController
scrollController
=
ScrollController
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
RefreshIndicator
(
onRefresh:
holdRefresh
,
child:
ListView
(
reverse:
true
,
controller:
scrollController
,
physics:
const
AlwaysScrollableScrollPhysics
(),
children:
const
<
Widget
>[
SizedBox
(
height:
200.0
,
child:
Text
(
'X'
),
),
SizedBox
(
height:
800.0
,
child:
Text
(
'Y'
),
),
],
),
),
),
);
scrollController
.
jumpTo
(
50.0
);
await
tester
.
fling
(
find
.
text
(
'X'
),
const
Offset
(
0.0
,
-
300.0
),
1000.0
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator settle animation
expect
(
tester
.
getCenter
(
find
.
byType
(
RefreshProgressIndicator
)).
dy
,
greaterThan
(
300.0
));
});
}
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