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
e25670a2
Unverified
Commit
e25670a2
authored
Feb 25, 2022
by
Jonah Williams
Committed by
GitHub
Feb 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] Provide gesture settings to regular gesture detectors (#99081)
parent
007b3ee0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
8 deletions
+101
-8
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+18
-8
gesture_config_regression_test.dart
...flutter/test/gestures/gesture_config_regression_test.dart
+83
-0
No files found.
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
e25670a2
...
@@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart';
...
@@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart';
import
'basic.dart'
;
import
'basic.dart'
;
import
'framework.dart'
;
import
'framework.dart'
;
import
'media_query.dart'
;
export
'package:flutter/gestures.dart'
show
export
'package:flutter/gestures.dart'
show
DragDownDetails
,
DragDownDetails
,
...
@@ -955,6 +956,7 @@ class GestureDetector extends StatelessWidget {
...
@@ -955,6 +956,7 @@ class GestureDetector extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
Map
<
Type
,
GestureRecognizerFactory
>
gestures
=
<
Type
,
GestureRecognizerFactory
>{};
final
Map
<
Type
,
GestureRecognizerFactory
>
gestures
=
<
Type
,
GestureRecognizerFactory
>{};
final
DeviceGestureSettings
?
gestureSettings
=
MediaQuery
.
maybeOf
(
context
)?.
gestureSettings
;
if
(
onTapDown
!=
null
||
if
(
onTapDown
!=
null
||
onTapUp
!=
null
||
onTapUp
!=
null
||
...
@@ -982,7 +984,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -982,7 +984,8 @@ class GestureDetector extends StatelessWidget {
..
onSecondaryTapCancel
=
onSecondaryTapCancel
..
onSecondaryTapCancel
=
onSecondaryTapCancel
..
onTertiaryTapDown
=
onTertiaryTapDown
..
onTertiaryTapDown
=
onTertiaryTapDown
..
onTertiaryTapUp
=
onTertiaryTapUp
..
onTertiaryTapUp
=
onTertiaryTapUp
..
onTertiaryTapCancel
=
onTertiaryTapCancel
;
..
onTertiaryTapCancel
=
onTertiaryTapCancel
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -994,7 +997,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -994,7 +997,8 @@ class GestureDetector extends StatelessWidget {
instance
instance
..
onDoubleTapDown
=
onDoubleTapDown
..
onDoubleTapDown
=
onDoubleTapDown
..
onDoubleTap
=
onDoubleTap
..
onDoubleTap
=
onDoubleTap
..
onDoubleTapCancel
=
onDoubleTapCancel
;
..
onDoubleTapCancel
=
onDoubleTapCancel
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1044,7 +1048,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1044,7 +1048,8 @@ class GestureDetector extends StatelessWidget {
..
onTertiaryLongPressStart
=
onTertiaryLongPressStart
..
onTertiaryLongPressStart
=
onTertiaryLongPressStart
..
onTertiaryLongPressMoveUpdate
=
onTertiaryLongPressMoveUpdate
..
onTertiaryLongPressMoveUpdate
=
onTertiaryLongPressMoveUpdate
..
onTertiaryLongPressUp
=
onTertiaryLongPressUp
..
onTertiaryLongPressUp
=
onTertiaryLongPressUp
..
onTertiaryLongPressEnd
=
onTertiaryLongPressEnd
;
..
onTertiaryLongPressEnd
=
onTertiaryLongPressEnd
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1063,7 +1068,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1063,7 +1068,8 @@ class GestureDetector extends StatelessWidget {
..
onUpdate
=
onVerticalDragUpdate
..
onUpdate
=
onVerticalDragUpdate
..
onEnd
=
onVerticalDragEnd
..
onEnd
=
onVerticalDragEnd
..
onCancel
=
onVerticalDragCancel
..
onCancel
=
onVerticalDragCancel
..
dragStartBehavior
=
dragStartBehavior
;
..
dragStartBehavior
=
dragStartBehavior
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1082,7 +1088,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1082,7 +1088,8 @@ class GestureDetector extends StatelessWidget {
..
onUpdate
=
onHorizontalDragUpdate
..
onUpdate
=
onHorizontalDragUpdate
..
onEnd
=
onHorizontalDragEnd
..
onEnd
=
onHorizontalDragEnd
..
onCancel
=
onHorizontalDragCancel
..
onCancel
=
onHorizontalDragCancel
..
dragStartBehavior
=
dragStartBehavior
;
..
dragStartBehavior
=
dragStartBehavior
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1101,7 +1108,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1101,7 +1108,8 @@ class GestureDetector extends StatelessWidget {
..
onUpdate
=
onPanUpdate
..
onUpdate
=
onPanUpdate
..
onEnd
=
onPanEnd
..
onEnd
=
onPanEnd
..
onCancel
=
onPanCancel
..
onCancel
=
onPanCancel
..
dragStartBehavior
=
dragStartBehavior
;
..
dragStartBehavior
=
dragStartBehavior
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1114,7 +1122,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1114,7 +1122,8 @@ class GestureDetector extends StatelessWidget {
..
onStart
=
onScaleStart
..
onStart
=
onScaleStart
..
onUpdate
=
onScaleUpdate
..
onUpdate
=
onScaleUpdate
..
onEnd
=
onScaleEnd
..
onEnd
=
onScaleEnd
..
dragStartBehavior
=
dragStartBehavior
;
..
dragStartBehavior
=
dragStartBehavior
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
@@ -1130,7 +1139,8 @@ class GestureDetector extends StatelessWidget {
...
@@ -1130,7 +1139,8 @@ class GestureDetector extends StatelessWidget {
..
onStart
=
onForcePressStart
..
onStart
=
onForcePressStart
..
onPeak
=
onForcePressPeak
..
onPeak
=
onForcePressPeak
..
onUpdate
=
onForcePressUpdate
..
onUpdate
=
onForcePressUpdate
..
onEnd
=
onForcePressEnd
;
..
onEnd
=
onForcePressEnd
..
gestureSettings
=
gestureSettings
;
},
},
);
);
}
}
...
...
packages/flutter/test/gestures/gesture_config_regression_test.dart
0 → 100644
View file @
e25670a2
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
TestResult
{
bool
dragStarted
=
false
;
bool
dragUpdate
=
false
;
}
class
MyHomePage
extends
StatefulWidget
{
const
MyHomePage
({
Key
?
key
,
required
this
.
testResult
})
:
super
(
key:
key
);
final
TestResult
testResult
;
@override
State
<
MyHomePage
>
createState
()
=>
_MyHomePageState
();
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
CustomScrollView
(
slivers:
<
Widget
>[
SliverFixedExtentList
(
itemExtent:
50.0
,
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
Container
(
alignment:
Alignment
.
center
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onVerticalDragDown:
(
DragDownDetails
details
)
{
widget
.
testResult
.
dragStarted
=
true
;
},
onVerticalDragUpdate:
(
DragUpdateDetails
details
){
widget
.
testResult
.
dragUpdate
=
true
;
},
onVerticalDragEnd:
(
_
)
{},
child:
Text
(
'List Item
$index
'
,
key:
ValueKey
<
int
>(
index
),
),
),
);
},
),
),
],
),
);
}
}
void
main
(
)
{
testWidgets
(
'Scroll Views get the same ScrollConfiguration as GestureDetectors'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ui
.
ViewConfiguration
(
gestureSettings:
ui
.
GestureSettings
(
physicalTouchSlop:
4
),
);
final
TestResult
result
=
TestResult
();
await
tester
.
pumpWidget
(
MaterialApp
(
title:
'Scroll Bug'
,
home:
MyHomePage
(
testResult:
result
),
));
// By dragging the scroll view more than the configured touch slop above but less than
// the framework default value, we demonstrate that this causes gesture detectors
// that do not receive the same gesture settings to fire at different times than would
// be expected.
final
Offset
start
=
tester
.
getCenter
(
find
.
byKey
(
const
ValueKey
<
int
>(
1
)));
await
tester
.
timedDragFrom
(
start
,
const
Offset
(
0
,
5
),
const
Duration
(
milliseconds:
50
));
await
tester
.
pumpAndSettle
();
expect
(
result
.
dragStarted
,
true
);
expect
(
result
.
dragUpdate
,
true
);
});
}
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