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
46b316c4
Commit
46b316c4
authored
Jun 08, 2017
by
Ian Hickson
Committed by
GitHub
Jun 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change RawGestureDetector API to be better for strong mode Dart. (#10553)
parent
b5365d93
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
216 additions
and
84 deletions
+216
-84
material_arc.dart
dev/manual_tests/lib/material_arc.dart
+14
-8
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+5
-0
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+169
-54
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+28
-22
No files found.
dev/manual_tests/lib/material_arc.dart
View file @
46b316c4
...
...
@@ -189,10 +189,13 @@ class _PointDemoState extends State<_PointDemo> {
return
new
RawGestureDetector
(
behavior:
_dragTarget
==
null
?
HitTestBehavior
.
deferToChild
:
HitTestBehavior
.
opaque
,
gestures:
<
Type
,
GestureRecognizerFactory
>{
ImmediateMultiDragGestureRecognizer:
(
ImmediateMultiDragGestureRecognizer
recognizer
)
{
// ignore: map_value_type_not_assignable, https://github.com/flutter/flutter/issues/5771
return
(
recognizer
??=
new
ImmediateMultiDragGestureRecognizer
())
..
onStart
=
_handleOnStart
;
}
ImmediateMultiDragGestureRecognizer:
new
GestureRecognizerFactoryWithHandlers
<
ImmediateMultiDragGestureRecognizer
>(
()
=>
new
ImmediateMultiDragGestureRecognizer
(),
(
ImmediateMultiDragGestureRecognizer
instance
)
{
instance
..
onStart
=
_handleOnStart
;
},
),
},
child:
new
ClipRect
(
child:
new
CustomPaint
(
...
...
@@ -359,10 +362,13 @@ class _RectangleDemoState extends State<_RectangleDemo> {
return
new
RawGestureDetector
(
behavior:
_dragTarget
==
null
?
HitTestBehavior
.
deferToChild
:
HitTestBehavior
.
opaque
,
gestures:
<
Type
,
GestureRecognizerFactory
>{
ImmediateMultiDragGestureRecognizer:
(
ImmediateMultiDragGestureRecognizer
recognizer
)
{
// ignore: map_value_type_not_assignable, https://github.com/flutter/flutter/issues/5771
return
(
recognizer
??=
new
ImmediateMultiDragGestureRecognizer
())
..
onStart
=
_handleOnStart
;
}
ImmediateMultiDragGestureRecognizer:
new
GestureRecognizerFactoryWithHandlers
<
ImmediateMultiDragGestureRecognizer
>(
()
=>
new
ImmediateMultiDragGestureRecognizer
(),
(
ImmediateMultiDragGestureRecognizer
instance
)
{
instance
..
onStart
=
_handleOnStart
;
},
),
},
child:
new
ClipRect
(
child:
new
CustomPaint
(
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
46b316c4
...
...
@@ -721,18 +721,22 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
NavigationGestureController
_backGestureController
;
bool
_shouldHandleBackGesture
()
{
assert
(
mounted
);
return
Theme
.
of
(
context
).
platform
==
TargetPlatform
.
iOS
&&
Navigator
.
canPop
(
context
);
}
void
_handleDragStart
(
DragStartDetails
details
)
{
assert
(
mounted
);
_backGestureController
=
Navigator
.
of
(
context
).
startPopGesture
();
}
void
_handleDragUpdate
(
DragUpdateDetails
details
)
{
assert
(
mounted
);
_backGestureController
?.
dragUpdate
(
details
.
primaryDelta
/
context
.
size
.
width
);
}
void
_handleDragEnd
(
DragEndDetails
details
)
{
assert
(
mounted
);
final
bool
willPop
=
_backGestureController
?.
dragEnd
(
details
.
velocity
.
pixelsPerSecond
.
dx
/
context
.
size
.
width
)
??
false
;
if
(
willPop
)
_currentBottomSheet
?.
close
();
...
...
@@ -740,6 +744,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
}
void
_handleDragCancel
()
{
assert
(
mounted
);
final
bool
willPop
=
_backGestureController
?.
dragEnd
(
0.0
)
??
false
;
if
(
willPop
)
_currentBottomSheet
?.
close
();
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
46b316c4
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/scrollable.dart
View file @
46b316c4
...
...
@@ -327,32 +327,38 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
switch
(
widget
.
axis
)
{
case
Axis
.
vertical
:
_gestureRecognizers
=
<
Type
,
GestureRecognizerFactory
>{
VerticalDragGestureRecognizer:
(
VerticalDragGestureRecognizer
recognizer
)
{
// ignore: map_value_type_not_assignable, https://github.com/flutter/flutter/issues/7173
return
(
recognizer
??=
new
VerticalDragGestureRecognizer
())
..
onDown
=
_handleDragDown
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onCancel
=
_handleDragCancel
..
minFlingDistance
=
_physics
?.
minFlingDistance
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
;
}
VerticalDragGestureRecognizer:
new
GestureRecognizerFactoryWithHandlers
<
VerticalDragGestureRecognizer
>(
()
=>
new
VerticalDragGestureRecognizer
(),
(
VerticalDragGestureRecognizer
instance
)
{
instance
..
onDown
=
_handleDragDown
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onCancel
=
_handleDragCancel
..
minFlingDistance
=
_physics
?.
minFlingDistance
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
;
},
),
};
break
;
case
Axis
.
horizontal
:
_gestureRecognizers
=
<
Type
,
GestureRecognizerFactory
>{
HorizontalDragGestureRecognizer:
(
HorizontalDragGestureRecognizer
recognizer
)
{
// ignore: map_value_type_not_assignable, https://github.com/flutter/flutter/issues/7173
return
(
recognizer
??=
new
HorizontalDragGestureRecognizer
())
..
onDown
=
_handleDragDown
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onCancel
=
_handleDragCancel
..
minFlingDistance
=
_physics
?.
minFlingDistance
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
;
}
HorizontalDragGestureRecognizer:
new
GestureRecognizerFactoryWithHandlers
<
HorizontalDragGestureRecognizer
>(
()
=>
new
HorizontalDragGestureRecognizer
(),
(
HorizontalDragGestureRecognizer
instance
)
{
instance
..
onDown
=
_handleDragDown
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onCancel
=
_handleDragCancel
..
minFlingDistance
=
_physics
?.
minFlingDistance
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
;
},
),
};
break
;
}
...
...
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