File tree Expand file tree Collapse file tree 4 files changed +38
-32
lines changed Expand file tree Collapse file tree 4 files changed +38
-32
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ part of 'chart_animation.dart';
33/// Provides color animation values.
44class ChartColorAnimation implements ChartAnimation {
55 Animation <Color ?>? _animation;
6+ CurvedAnimation ? _listener;
7+
68 Color _lastColor = Colors .transparent;
79
810 ChartColorAnimation ();
@@ -21,6 +23,7 @@ class ChartColorAnimation implements ChartAnimation {
2123 @override
2224 void dispose () {
2325 _animation = null ;
26+ _listener? .dispose ();
2427 }
2528
2629 /// Initialize animation.
@@ -31,15 +34,14 @@ class ChartColorAnimation implements ChartAnimation {
3134 Color ? initialColor,
3235 ChartColorAnimation ? oldAnimation,
3336 }) {
34- final Animation <Color ?> animation = ColorTween (
37+ _listener? .dispose ();
38+ _listener = CurvedAnimation (
39+ parent: controller,
40+ curve: curve,
41+ );
42+ _animation = ColorTween (
3543 begin: oldAnimation? ._lastColor ?? initialColor ?? Colors .transparent,
3644 end: color,
37- ).animate (
38- CurvedAnimation (
39- parent: controller,
40- curve: curve,
41- ),
42- );
43- _animation = animation;
45+ ).animate (_listener! );
4446 }
4547}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ part of 'chart_animation.dart';
33/// Provides position animation values.
44class ChartPositionAnimation implements ChartAnimation {
55 Animation <Offset >? _animation;
6+ CurvedAnimation ? _listener;
67 Offset _lastPosition = Offset .zero;
78
89 ChartPositionAnimation ();
@@ -21,6 +22,7 @@ class ChartPositionAnimation implements ChartAnimation {
2122 @override
2223 void dispose () {
2324 _animation = null ;
25+ _listener? .dispose ();
2426 }
2527
2628 /// Initialize animation.
@@ -31,15 +33,14 @@ class ChartPositionAnimation implements ChartAnimation {
3133 Offset ? initialPosition,
3234 ChartPositionAnimation ? oldAnimation,
3335 }) {
34- final Animation <Offset > animation = Tween <Offset >(
36+ _listener? .dispose ();
37+ _listener = CurvedAnimation (
38+ parent: controller,
39+ curve: curve,
40+ );
41+ _animation = Tween <Offset >(
3542 begin: oldAnimation? ._lastPosition ?? initialPosition ?? position,
3643 end: position,
37- ).animate (
38- CurvedAnimation (
39- parent: controller,
40- curve: curve,
41- ),
42- );
43- _animation = animation;
44+ ).animate (_listener! );
4445 }
4546}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ part of 'chart_animation.dart';
33/// Provides size animation values.
44class ChartSizeAnimation implements ChartAnimation {
55 Animation <Size >? _animation;
6+ CurvedAnimation ? _listener;
67 Size _lastSize = Size .zero;
78
89 ChartSizeAnimation ();
@@ -21,6 +22,7 @@ class ChartSizeAnimation implements ChartAnimation {
2122 @override
2223 void dispose () {
2324 _animation = null ;
25+ _listener? .dispose ();
2426 }
2527
2628 /// Initialize animation.
@@ -31,15 +33,14 @@ class ChartSizeAnimation implements ChartAnimation {
3133 Size ? initialSize,
3234 ChartSizeAnimation ? oldAnimation,
3335 }) {
34- final Animation <Size > animation = Tween <Size >(
36+ _listener? .dispose ();
37+ _listener = CurvedAnimation (
38+ parent: controller,
39+ curve: curve,
40+ );
41+ _animation = Tween <Size >(
3542 begin: oldAnimation? ._lastSize ?? initialSize ?? size,
3643 end: size,
37- ).animate (
38- CurvedAnimation (
39- parent: controller,
40- curve: curve,
41- ),
42- );
43- _animation = animation;
44+ ).animate (_listener! );
4445 }
4546}
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ part of 'chart_animation.dart';
33/// Provides text style animation values.
44class ChartTextStyleAnimation implements ChartAnimation {
55 Animation <TextStyle >? _animation;
6+ CurvedAnimation ? _listener;
7+
68 TextStyle _lastTextStyle = const TextStyle (
79 color: Colors .transparent,
810 );
@@ -26,6 +28,7 @@ class ChartTextStyleAnimation implements ChartAnimation {
2628 @override
2729 void dispose () {
2830 _animation = null ;
31+ _listener? .dispose ();
2932 }
3033
3134 /// Initialize animation.
@@ -36,19 +39,18 @@ class ChartTextStyleAnimation implements ChartAnimation {
3639 TextStyle ? initialTextSyle,
3740 ChartTextStyleAnimation ? oldAnimation,
3841 }) {
39- final Animation <TextStyle > animation = TextStyleTween (
42+ _listener? .dispose ();
43+ _listener = CurvedAnimation (
44+ parent: controller,
45+ curve: curve,
46+ );
47+ _animation = TextStyleTween (
4048 begin: oldAnimation? ._lastTextStyle ??
4149 initialTextSyle ??
4250 const TextStyle (
4351 color: Colors .transparent,
4452 ),
4553 end: textStyle,
46- ).animate (
47- CurvedAnimation (
48- parent: controller,
49- curve: curve,
50- ),
51- );
52- _animation = animation;
54+ ).animate (_listener! );
5355 }
5456}
You can’t perform that action at this time.
0 commit comments