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
1a9ea39a
Unverified
Commit
1a9ea39a
authored
Sep 23, 2020
by
TheBiirb
Committed by
GitHub
Sep 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Dismissible's HitTestBehavior an argument (#64379)
parent
8ed0ac53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
dismissible.dart
packages/flutter/lib/src/widgets/dismissible.dart
+7
-1
dismissible_test.dart
packages/flutter/test/widgets/dismissible_test.dart
+69
-0
No files found.
packages/flutter/lib/src/widgets/dismissible.dart
View file @
1a9ea39a
...
...
@@ -94,6 +94,7 @@ class Dismissible extends StatefulWidget {
this
.
movementDuration
=
const
Duration
(
milliseconds:
200
),
this
.
crossAxisEndOffset
=
0.0
,
this
.
dragStartBehavior
=
DragStartBehavior
.
start
,
this
.
behavior
=
HitTestBehavior
.
opaque
,
})
:
assert
(
key
!=
null
),
assert
(
secondaryBackground
==
null
||
background
!=
null
),
assert
(
dragStartBehavior
!=
null
),
...
...
@@ -185,6 +186,11 @@ class Dismissible extends StatefulWidget {
/// * [DragGestureRecognizer.dragStartBehavior], which gives an example for the different behaviors.
final
DragStartBehavior
dragStartBehavior
;
/// How to behave during hit tests.
///
/// This defaults to [HitTestBehavior.opaque].
final
HitTestBehavior
behavior
;
@override
_DismissibleState
createState
()
=>
_DismissibleState
();
}
...
...
@@ -574,7 +580,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
onVerticalDragStart:
_directionIsXAxis
?
null
:
_handleDragStart
,
onVerticalDragUpdate:
_directionIsXAxis
?
null
:
_handleDragUpdate
,
onVerticalDragEnd:
_directionIsXAxis
?
null
:
_handleDragEnd
,
behavior:
HitTestBehavior
.
opaque
,
behavior:
widget
.
behavior
,
child:
content
,
dragStartBehavior:
widget
.
dragStartBehavior
,
);
...
...
packages/flutter/test/widgets/dismissible_test.dart
View file @
1a9ea39a
...
...
@@ -798,4 +798,73 @@ void main() {
' handler has fired.
\n
'
,
);
});
testWidgets
(
'Dismissible.behavior should behave correctly during hit testing'
,
(
WidgetTester
tester
)
async
{
bool
didReceivePointerDown
=
false
;
Widget
buildStack
({
Widget
child
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Stack
(
children:
<
Widget
>[
Listener
(
onPointerDown:
(
_
)
{
didReceivePointerDown
=
true
;
},
child:
Container
(
width:
100.0
,
height:
100.0
,
color:
const
Color
(
0xFF00FF00
),
),
),
child
,
],
),
);
}
await
tester
.
pumpWidget
(
buildStack
(
child:
const
Dismissible
(
key:
ValueKey
<
int
>(
1
),
child:
SizedBox
(
width:
100.0
,
height:
100.0
,
),
),
),
);
await
tester
.
tapAt
(
const
Offset
(
10.0
,
10.0
));
expect
(
didReceivePointerDown
,
isFalse
);
Future
<
void
>
pumpWidgetTree
(
HitTestBehavior
behavior
)
{
return
tester
.
pumpWidget
(
buildStack
(
child:
Dismissible
(
key:
const
ValueKey
<
int
>(
1
),
behavior:
behavior
,
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
,
),
),
),
);
}
didReceivePointerDown
=
false
;
await
pumpWidgetTree
(
HitTestBehavior
.
deferToChild
);
await
tester
.
tapAt
(
const
Offset
(
10.0
,
10.0
));
expect
(
didReceivePointerDown
,
isTrue
);
didReceivePointerDown
=
false
;
await
pumpWidgetTree
(
HitTestBehavior
.
opaque
);
await
tester
.
tapAt
(
const
Offset
(
10.0
,
10.0
));
expect
(
didReceivePointerDown
,
isFalse
);
didReceivePointerDown
=
false
;
await
pumpWidgetTree
(
HitTestBehavior
.
translucent
);
await
tester
.
tapAt
(
const
Offset
(
10.0
,
10.0
));
expect
(
didReceivePointerDown
,
isTrue
);
});
}
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