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
a4ae59ba
Unverified
Commit
a4ae59ba
authored
Feb 11, 2021
by
Pedro Massango
Committed by
GitHub
Feb 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "Support configurable hit test behavior on Draggable and DragTarget" (#74047)
parent
51078bcb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
1 deletion
+57
-1
AUTHORS
AUTHORS
+1
-0
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+14
-1
draggable_test.dart
packages/flutter/test/widgets/draggable_test.dart
+42
-0
No files found.
AUTHORS
View file @
a4ae59ba
...
...
@@ -72,3 +72,4 @@ nt4f04uNd <nt4f04und@gmail.com>
Anurag Roy <anuragr9847@gmail.com>
Andrey Kabylin <andrey@kabylin.ru>
vimerzhao <vimerzhao@gmail.com>
Pedro Massango <pedromassango.developer@gmail.com>
packages/flutter/lib/src/widgets/drag_target.dart
View file @
a4ae59ba
...
...
@@ -199,6 +199,7 @@ class Draggable<T extends Object> extends StatefulWidget {
this
.
onDragCompleted
,
this
.
ignoringFeedbackSemantics
=
true
,
this
.
rootOverlay
=
false
,
this
.
hitTestBehavior
=
HitTestBehavior
.
deferToChild
,
})
:
assert
(
child
!=
null
),
assert
(
feedback
!=
null
),
assert
(
ignoringFeedbackSemantics
!=
null
),
...
...
@@ -350,6 +351,11 @@ class Draggable<T extends Object> extends StatefulWidget {
/// Defaults to false.
final
bool
rootOverlay
;
/// How to behave during hit test.
///
/// Defaults to [HitTestBehavior.deferToChild].
final
HitTestBehavior
hitTestBehavior
;
/// Creates a gesture recognizer that recognizes the start of the drag.
///
/// Subclasses can override this function to customize when they start
...
...
@@ -539,6 +545,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
_activeCount
<
widget
.
maxSimultaneousDrags
!;
final
bool
showChild
=
_activeCount
==
0
||
widget
.
childWhenDragging
==
null
;
return
Listener
(
behavior:
widget
.
hitTestBehavior
,
onPointerDown:
canDrag
?
_routePointer
:
null
,
child:
showChild
?
widget
.
child
:
widget
.
childWhenDragging
,
);
...
...
@@ -616,6 +623,7 @@ class DragTarget<T extends Object> extends StatefulWidget {
this
.
onAcceptWithDetails
,
this
.
onLeave
,
this
.
onMove
,
this
.
hitTestBehavior
=
HitTestBehavior
.
translucent
,
})
:
super
(
key:
key
);
/// Called to build the contents of this widget.
...
...
@@ -652,6 +660,11 @@ class DragTarget<T extends Object> extends StatefulWidget {
/// Note that this includes entering and leaving the target.
final
DragTargetMove
?
onMove
;
/// How to behave during hit testing.
///
/// Defaults to [HitTestBehavior.translucent].
final
HitTestBehavior
hitTestBehavior
;
@override
_DragTargetState
<
T
>
createState
()
=>
_DragTargetState
<
T
>();
}
...
...
@@ -727,7 +740,7 @@ class _DragTargetState<T extends Object> extends State<DragTarget<T>> {
assert
(
widget
.
builder
!=
null
);
return
MetaData
(
metaData:
this
,
behavior:
HitTestBehavior
.
translucent
,
behavior:
widget
.
hitTestBehavior
,
child:
widget
.
builder
(
context
,
_mapAvatarsToData
<
T
>(
_candidateAvatars
),
_mapAvatarsToData
<
Object
>(
_rejectedAvatars
)),
);
}
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
a4ae59ba
...
...
@@ -2874,6 +2874,48 @@ void main() {
),
ignoreTransform:
true
,
ignoreRect:
true
));
semantics
.
dispose
();
});
testWidgets
(
'configurable Draggable hit test behavior'
,
(
WidgetTester
tester
)
async
{
const
HitTestBehavior
hitTestBehavior
=
HitTestBehavior
.
deferToChild
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
children:
<
Widget
>[
Draggable
<
int
>(
hitTestBehavior:
hitTestBehavior
,
feedback:
Container
(
height:
50.0
,
child:
const
Text
(
'Draggable'
)),
child:
Container
(
height:
50.0
,
child:
const
Text
(
'Target'
)),
),
],
),
),
);
expect
(
tester
.
widget
<
Listener
>(
find
.
byType
(
Listener
).
first
).
behavior
,
hitTestBehavior
);
});
testWidgets
(
'configurable DragTarget hit test behavior'
,
(
WidgetTester
tester
)
async
{
const
HitTestBehavior
hitTestBehavior
=
HitTestBehavior
.
deferToChild
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
children:
<
Widget
>[
DragTarget
<
int
>(
hitTestBehavior:
hitTestBehavior
,
builder:
(
BuildContext
context
,
List
<
int
?>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
),
],
),
),
);
expect
(
tester
.
widget
<
MetaData
>(
find
.
byType
(
MetaData
)).
behavior
,
hitTestBehavior
);
});
}
Future
<
void
>
_testLongPressDraggableHapticFeedback
({
required
WidgetTester
tester
,
required
bool
hapticFeedbackOnStart
,
required
int
expectedHapticFeedbackCount
})
async
{
...
...
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