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
8e6d57b7
Unverified
Commit
8e6d57b7
authored
Mar 04, 2022
by
Jonah Williams
Committed by
GitHub
Mar 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] add gesture settings to draggable (#99567)
parent
59859df1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
5 deletions
+79
-5
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+7
-0
gesture_config_regression_test.dart
...flutter/test/gestures/gesture_config_regression_test.dart
+72
-5
No files found.
packages/flutter/lib/src/widgets/drag_target.dart
View file @
8e6d57b7
...
@@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
...
@@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
import
'basic.dart'
;
import
'basic.dart'
;
import
'binding.dart'
;
import
'binding.dart'
;
import
'framework.dart'
;
import
'framework.dart'
;
import
'media_query.dart'
;
import
'overlay.dart'
;
import
'overlay.dart'
;
/// Signature for determining whether the given data will be accepted by a [DragTarget].
/// Signature for determining whether the given data will be accepted by a [DragTarget].
...
@@ -500,6 +501,12 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
...
@@ -500,6 +501,12 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
super
.
dispose
();
super
.
dispose
();
}
}
@override
void
didChangeDependencies
()
{
_recognizer
!.
gestureSettings
=
MediaQuery
.
maybeOf
(
context
)?.
gestureSettings
;
super
.
didChangeDependencies
();
}
// This gesture recognizer has an unusual lifetime. We want to support the use
// This gesture recognizer has an unusual lifetime. We want to support the use
// case of removing the Draggable from the tree in the middle of a drag. That
// case of removing the Draggable from the tree in the middle of a drag. That
// means we need to keep this recognizer alive after this state object has
// means we need to keep this recognizer alive after this state object has
...
...
packages/flutter/test/gestures/gesture_config_regression_test.dart
View file @
8e6d57b7
...
@@ -13,16 +13,16 @@ class TestResult {
...
@@ -13,16 +13,16 @@ class TestResult {
bool
dragUpdate
=
false
;
bool
dragUpdate
=
false
;
}
}
class
MyHomePag
e
extends
StatefulWidget
{
class
NestedScrollableCas
e
extends
StatefulWidget
{
const
MyHomePag
e
({
Key
?
key
,
required
this
.
testResult
})
:
super
(
key:
key
);
const
NestedScrollableCas
e
({
Key
?
key
,
required
this
.
testResult
})
:
super
(
key:
key
);
final
TestResult
testResult
;
final
TestResult
testResult
;
@override
@override
State
<
MyHomePage
>
createState
()
=>
_MyHomePag
eState
();
State
<
NestedScrollableCase
>
createState
()
=>
_NestedScrollableCas
eState
();
}
}
class
_
MyHomePageState
extends
State
<
MyHomePag
e
>
{
class
_
NestedScrollableCaseState
extends
State
<
NestedScrollableCas
e
>
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -57,6 +57,50 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -57,6 +57,50 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
}
}
class
NestedDragableCase
extends
StatefulWidget
{
const
NestedDragableCase
({
Key
?
key
,
required
this
.
testResult
})
:
super
(
key:
key
);
final
TestResult
testResult
;
@override
State
<
NestedDragableCase
>
createState
()
=>
_NestedDragableCaseState
();
}
class
_NestedDragableCaseState
extends
State
<
NestedDragableCase
>
{
@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:
Draggable
<
Object
>(
key:
ValueKey
<
int
>(
index
),
feedback:
const
Text
(
'Dragging'
),
child:
Text
(
'List Item
$index
'
),
onDragStarted:
()
{
widget
.
testResult
.
dragStarted
=
true
;
},
onDragUpdate:
(
DragUpdateDetails
details
){
widget
.
testResult
.
dragUpdate
=
true
;
},
onDragEnd:
(
_
)
{},
),
);
},
),
),
],
),
);
}
}
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Scroll Views get the same ScrollConfiguration as GestureDetectors'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Scroll Views get the same ScrollConfiguration as GestureDetectors'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ui
.
ViewConfiguration
(
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ui
.
ViewConfiguration
(
...
@@ -66,7 +110,30 @@ void main() {
...
@@ -66,7 +110,30 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
title:
'Scroll Bug'
,
title:
'Scroll Bug'
,
home:
MyHomePage
(
testResult:
result
),
home:
NestedScrollableCase
(
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
);
});
testWidgets
(
'Scroll Views get the same ScrollConfiguration as Draggables'
,
(
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:
NestedDragableCase
(
testResult:
result
),
));
));
// By dragging the scroll view more than the configured touch slop above but less than
// By dragging the scroll view more than the configured touch slop above but less than
...
...
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