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
12ec91a5
Unverified
Commit
12ec91a5
authored
Oct 20, 2021
by
Aliaksei Chorny
Committed by
GitHub
Oct 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The covered child in AnimatedCrossFade should not get touch events (#91349)
parent
15de4aa4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
12 deletions
+64
-12
animated_cross_fade.dart
packages/flutter/lib/src/widgets/animated_cross_fade.dart
+17
-12
animated_cross_fade_test.dart
packages/flutter/test/widgets/animated_cross_fade_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/animated_cross_fade.dart
View file @
12ec91a5
...
...
@@ -342,11 +342,13 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
bottomChild
=
TickerMode
(
key:
bottomKey
,
enabled:
_isTransitioning
,
child:
ExcludeSemantics
(
// Always exclude the semantics of the widget that's fading out.
child:
ExcludeFocus
(
child:
FadeTransition
(
opacity:
bottomAnimation
,
child:
bottomChild
,
child:
IgnorePointer
(
child:
ExcludeSemantics
(
// Always exclude the semantics of the widget that's fading out.
child:
ExcludeFocus
(
child:
FadeTransition
(
opacity:
bottomAnimation
,
child:
bottomChild
,
),
),
),
),
...
...
@@ -354,13 +356,16 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
topChild
=
TickerMode
(
key:
topKey
,
enabled:
true
,
// Top widget always has its animations enabled.
child:
ExcludeSemantics
(
excluding:
false
,
// Always publish semantics for the widget that's fading in.
child:
ExcludeFocus
(
excluding:
false
,
child:
FadeTransition
(
opacity:
topAnimation
,
child:
topChild
,
child:
IgnorePointer
(
ignoring:
false
,
child:
ExcludeSemantics
(
excluding:
false
,
// Always publish semantics for the widget that's fading in.
child:
ExcludeFocus
(
excluding:
false
,
child:
FadeTransition
(
opacity:
topAnimation
,
child:
topChild
,
),
),
),
),
...
...
packages/flutter/test/widgets/animated_cross_fade_test.dart
View file @
12ec91a5
...
...
@@ -384,6 +384,53 @@ void main() {
await
tester
.
pump
();
expect
(
hiddenNode
.
hasPrimaryFocus
,
isFalse
);
});
testWidgets
(
'AnimatedCrossFade second child do not receive touch events'
,
(
WidgetTester
tester
)
async
{
int
numberOfTouchEventNoticed
=
0
;
Future
<
void
>
buildAnimatedFrame
(
CrossFadeState
crossFadeState
)
{
return
tester
.
pumpWidget
(
SizedBox
(
width:
300
,
height:
600
,
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
AnimatedCrossFade
(
firstChild:
const
Text
(
'AAA'
),
secondChild:
TextButton
(
style:
TextButton
.
styleFrom
(
minimumSize:
const
Size
(
double
.
infinity
,
600
)),
onPressed:
()
{
numberOfTouchEventNoticed
++;
},
child:
const
Text
(
'BBB'
),
),
crossFadeState:
crossFadeState
,
duration:
const
Duration
(
milliseconds:
50
),
),
),
),
);
}
Future
<
void
>
touchSecondButton
()
async
{
final
TestGesture
gestureTouchSecondButton
=
await
tester
.
startGesture
(
const
Offset
(
150
,
300
));
return
gestureTouchSecondButton
.
up
();
}
await
buildAnimatedFrame
(
CrossFadeState
.
showSecond
);
await
touchSecondButton
();
expect
(
numberOfTouchEventNoticed
,
1
);
await
buildAnimatedFrame
(
CrossFadeState
.
showFirst
);
await
touchSecondButton
();
await
touchSecondButton
();
expect
(
numberOfTouchEventNoticed
,
1
);
});
}
class
_TickerWatchingWidget
extends
StatefulWidget
{
...
...
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