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
89a00fc7
Unverified
Commit
89a00fc7
authored
May 18, 2020
by
LongCatIsLooong
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix segment hit test behavior (#57461)
parent
0423809c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
segmented_control.dart
packages/flutter/lib/src/cupertino/segmented_control.dart
+1
-0
segmented_control_test.dart
packages/flutter/test/cupertino/segmented_control_test.dart
+38
-0
sliding_segmented_control_test.dart
...lutter/test/cupertino/sliding_segmented_control_test.dart
+2
-1
No files found.
packages/flutter/lib/src/cupertino/segmented_control.dart
View file @
89a00fc7
...
...
@@ -382,6 +382,7 @@ class _SegmentedControlState<T> extends State<CupertinoSegmentedControl<T>>
);
child
=
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onTapDown:
(
TapDownDetails
event
)
{
_onTapDown
(
currentKey
);
},
...
...
packages/flutter/test/cupertino/segmented_control_test.dart
View file @
89a00fc7
...
...
@@ -926,6 +926,44 @@ void main() {
expect
(
sharedValue
,
0
);
});
testWidgets
(
'Segment still hittable with a child that has no hitbox'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/57326.
final
Map
<
int
,
Widget
>
children
=
<
int
,
Widget
>{};
children
[
0
]
=
const
Text
(
'Child 1'
);
children
[
1
]
=
const
SizedBox
();
int
sharedValue
=
0
;
await
tester
.
pumpWidget
(
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
boilerplate
(
child:
CupertinoSegmentedControl
<
int
>(
key:
const
ValueKey
<
String
>(
'Segmented Control'
),
children:
children
,
onValueChanged:
(
int
newValue
)
{
setState
(()
{
sharedValue
=
newValue
;
});
},
groupValue:
sharedValue
,
),
);
},
),
);
expect
(
sharedValue
,
0
);
final
Offset
centerOfTwo
=
tester
.
getCenter
(
find
.
byWidget
(
children
[
1
]));
// Tap within the bounds of children[1], but not at the center.
// children[1] is a SizedBox thus not hittable by itself.
await
tester
.
tapAt
(
centerOfTwo
+
const
Offset
(
10
,
0
));
expect
(
sharedValue
,
1
);
});
testWidgets
(
'Animation is correct when the selected segment changes'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
setupSimpleSegmentedControl
());
...
...
packages/flutter/test/cupertino/sliding_segmented_control_test.dart
View file @
89a00fc7
...
...
@@ -776,7 +776,8 @@ void main() {
expect
(
groupValue
,
0
);
final
Offset
centerOfTwo
=
tester
.
getCenter
(
find
.
byWidget
(
children
[
1
]));
// Tap just inside segment bounds
// Tap within the bounds of children[1], but not at the center.
// children[1] is a SizedBox thus not hittable by itself.
await
tester
.
tapAt
(
centerOfTwo
+
const
Offset
(
10
,
0
));
expect
(
groupValue
,
1
);
...
...
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