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
2ca823d4
Unverified
Commit
2ca823d4
authored
Oct 07, 2021
by
Tomek Polański
Committed by
GitHub
Oct 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Making AnimatedCrossFade more null safe (#91187)
parent
bfa4bdbf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
animated_cross_fade.dart
packages/flutter/lib/src/widgets/animated_cross_fade.dart
+12
-12
No files found.
packages/flutter/lib/src/widgets/animated_cross_fade.dart
View file @
2ca823d4
...
...
@@ -248,7 +248,7 @@ class AnimatedCrossFade extends StatefulWidget {
}
class
_AnimatedCrossFadeState
extends
State
<
AnimatedCrossFade
>
with
TickerProviderStateMixin
{
AnimationController
?
_controller
;
late
AnimationController
_controller
;
late
Animation
<
double
>
_firstAnimation
;
late
Animation
<
double
>
_secondAnimation
;
...
...
@@ -261,10 +261,10 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
vsync:
this
,
);
if
(
widget
.
crossFadeState
==
CrossFadeState
.
showSecond
)
_controller
!
.
value
=
1.0
;
_controller
.
value
=
1.0
;
_firstAnimation
=
_initAnimation
(
widget
.
firstCurve
,
true
);
_secondAnimation
=
_initAnimation
(
widget
.
secondCurve
,
false
);
_controller
!
.
addStatusListener
((
AnimationStatus
status
)
{
_controller
.
addStatusListener
((
AnimationStatus
status
)
{
setState
(()
{
// Trigger a rebuild because it depends on _isTransitioning, which
// changes its value together with animation status.
...
...
@@ -273,7 +273,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
}
Animation
<
double
>
_initAnimation
(
Curve
curve
,
bool
inverted
)
{
Animation
<
double
>
result
=
_controller
!
.
drive
(
CurveTween
(
curve:
curve
));
Animation
<
double
>
result
=
_controller
.
drive
(
CurveTween
(
curve:
curve
));
if
(
inverted
)
result
=
result
.
drive
(
Tween
<
double
>(
begin:
1.0
,
end:
0.0
));
return
result
;
...
...
@@ -281,7 +281,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
@override
void
dispose
()
{
_controller
!
.
dispose
();
_controller
.
dispose
();
super
.
dispose
();
}
...
...
@@ -289,9 +289,9 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
void
didUpdateWidget
(
AnimatedCrossFade
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
duration
!=
oldWidget
.
duration
)
_controller
!
.
duration
=
widget
.
duration
;
_controller
.
duration
=
widget
.
duration
;
if
(
widget
.
reverseDuration
!=
oldWidget
.
reverseDuration
)
_controller
!
.
reverseDuration
=
widget
.
reverseDuration
;
_controller
.
reverseDuration
=
widget
.
reverseDuration
;
if
(
widget
.
firstCurve
!=
oldWidget
.
firstCurve
)
_firstAnimation
=
_initAnimation
(
widget
.
firstCurve
,
true
);
if
(
widget
.
secondCurve
!=
oldWidget
.
secondCurve
)
...
...
@@ -299,24 +299,24 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
if
(
widget
.
crossFadeState
!=
oldWidget
.
crossFadeState
)
{
switch
(
widget
.
crossFadeState
)
{
case
CrossFadeState
.
showFirst
:
_controller
!
.
reverse
();
_controller
.
reverse
();
break
;
case
CrossFadeState
.
showSecond
:
_controller
!
.
forward
();
_controller
.
forward
();
break
;
}
}
}
/// Whether we're in the middle of cross-fading this frame.
bool
get
_isTransitioning
=>
_controller
!.
status
==
AnimationStatus
.
forward
||
_controller
!
.
status
==
AnimationStatus
.
reverse
;
bool
get
_isTransitioning
=>
_controller
.
status
==
AnimationStatus
.
forward
||
_controller
.
status
==
AnimationStatus
.
reverse
;
@override
Widget
build
(
BuildContext
context
)
{
const
Key
kFirstChildKey
=
ValueKey
<
CrossFadeState
>(
CrossFadeState
.
showFirst
);
const
Key
kSecondChildKey
=
ValueKey
<
CrossFadeState
>(
CrossFadeState
.
showSecond
);
final
bool
transitioningForwards
=
_controller
!
.
status
==
AnimationStatus
.
completed
||
_controller
!
.
status
==
AnimationStatus
.
forward
;
final
bool
transitioningForwards
=
_controller
.
status
==
AnimationStatus
.
completed
||
_controller
.
status
==
AnimationStatus
.
forward
;
final
Key
topKey
;
Widget
topChild
;
final
Animation
<
double
>
topAnimation
;
...
...
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