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
b26970b1
Unverified
Commit
b26970b1
authored
Nov 05, 2020
by
LongCatIsLooong
Committed by
GitHub
Nov 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cancel drag or hold when scrolling is disabled. (#69732)
parent
0963d725
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+4
-0
scrollable_test.dart
packages/flutter/test/widgets/scrollable_test.dart
+76
-0
No files found.
packages/flutter/lib/src/widgets/scrollable.dart
View file @
b26970b1
...
...
@@ -498,6 +498,10 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
return
;
if
(!
canDrag
)
{
_gestureRecognizers
=
const
<
Type
,
GestureRecognizerFactory
>{};
// Cancel the active hold/drag (if any) because the gesture recognizers
// will soon be disposed by our RawGestureDetector, and we won't be
// receiving pointer up events to cancel the hold/drag.
_handleDragCancel
();
}
else
{
switch
(
widget
.
axis
)
{
case
Axis
.
vertical
:
...
...
packages/flutter/test/widgets/scrollable_test.dart
View file @
b26970b1
...
...
@@ -368,6 +368,82 @@ void main() {
expect
(
getScrollOffset
(
tester
),
20.0
);
});
group
(
'setCanDrag to false with active drag gesture: '
,
()
{
Future
<
void
>
pumpTestWidget
(
WidgetTester
tester
,
{
required
bool
canDrag
})
{
return
tester
.
pumpWidget
(
MaterialApp
(
home:
CustomScrollView
(
physics:
canDrag
?
const
AlwaysScrollableScrollPhysics
()
:
const
NeverScrollableScrollPhysics
(),
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
SizedBox
(
height:
2000
,
child:
GestureDetector
(
onTap:
()
{},),
),
)],
),
),
);
}
testWidgets
(
'Hold does not disable user interaction'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/66816.
await
pumpTestWidget
(
tester
,
canDrag:
true
);
final
RenderIgnorePointer
renderIgnorePointer
=
tester
.
renderObject
<
RenderIgnorePointer
>(
find
.
descendant
(
of:
find
.
byType
(
CustomScrollView
),
matching:
find
.
byType
(
IgnorePointer
)),
);
expect
(
renderIgnorePointer
.
ignoring
,
false
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
Viewport
)));
expect
(
renderIgnorePointer
.
ignoring
,
false
);
await
pumpTestWidget
(
tester
,
canDrag:
false
);
expect
(
renderIgnorePointer
.
ignoring
,
false
);
await
gesture
.
up
();
expect
(
renderIgnorePointer
.
ignoring
,
false
);
});
testWidgets
(
'Drag disables user interaction when recognized'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/66816.
await
pumpTestWidget
(
tester
,
canDrag:
true
);
final
RenderIgnorePointer
renderIgnorePointer
=
tester
.
renderObject
<
RenderIgnorePointer
>(
find
.
descendant
(
of:
find
.
byType
(
CustomScrollView
),
matching:
find
.
byType
(
IgnorePointer
)),
);
expect
(
renderIgnorePointer
.
ignoring
,
false
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
Viewport
)));
expect
(
renderIgnorePointer
.
ignoring
,
false
);
await
gesture
.
moveBy
(
const
Offset
(
0
,
-
100
));
// Starts ignoring when the drag is recognized.
expect
(
renderIgnorePointer
.
ignoring
,
true
);
await
pumpTestWidget
(
tester
,
canDrag:
false
);
expect
(
renderIgnorePointer
.
ignoring
,
false
);
await
gesture
.
up
();
expect
(
renderIgnorePointer
.
ignoring
,
false
);
});
testWidgets
(
'Ballistic disables user interaction until it stops'
,
(
WidgetTester
tester
)
async
{
await
pumpTestWidget
(
tester
,
canDrag:
true
);
final
RenderIgnorePointer
renderIgnorePointer
=
tester
.
renderObject
<
RenderIgnorePointer
>(
find
.
descendant
(
of:
find
.
byType
(
CustomScrollView
),
matching:
find
.
byType
(
IgnorePointer
)),
);
expect
(
renderIgnorePointer
.
ignoring
,
false
);
// Starts ignoring when the drag is recognized.
await
tester
.
fling
(
find
.
byType
(
Viewport
),
const
Offset
(
0
,
-
100
),
1000
);
expect
(
renderIgnorePointer
.
ignoring
,
true
);
await
tester
.
pump
();
// When the activity ends we should stop ignoring pointers.
await
tester
.
pumpAndSettle
();
expect
(
renderIgnorePointer
.
ignoring
,
false
);
});
});
testWidgets
(
"Keyboard scrolling doesn't happen if scroll physics are set to NeverScrollableScrollPhysics"
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
await
tester
.
pumpWidget
(
...
...
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