File tree 4 files changed +38
-32
lines changed
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';
3
3
/// Provides color animation values.
4
4
class ChartColorAnimation implements ChartAnimation {
5
5
Animation <Color ?>? _animation;
6
+ CurvedAnimation ? _listener;
7
+
6
8
Color _lastColor = Colors .transparent;
7
9
8
10
ChartColorAnimation ();
@@ -21,6 +23,7 @@ class ChartColorAnimation implements ChartAnimation {
21
23
@override
22
24
void dispose () {
23
25
_animation = null ;
26
+ _listener? .dispose ();
24
27
}
25
28
26
29
/// Initialize animation.
@@ -31,15 +34,14 @@ class ChartColorAnimation implements ChartAnimation {
31
34
Color ? initialColor,
32
35
ChartColorAnimation ? oldAnimation,
33
36
}) {
34
- final Animation <Color ?> animation = ColorTween (
37
+ _listener? .dispose ();
38
+ _listener = CurvedAnimation (
39
+ parent: controller,
40
+ curve: curve,
41
+ );
42
+ _animation = ColorTween (
35
43
begin: oldAnimation? ._lastColor ?? initialColor ?? Colors .transparent,
36
44
end: color,
37
- ).animate (
38
- CurvedAnimation (
39
- parent: controller,
40
- curve: curve,
41
- ),
42
- );
43
- _animation = animation;
45
+ ).animate (_listener! );
44
46
}
45
47
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ part of 'chart_animation.dart';
3
3
/// Provides position animation values.
4
4
class ChartPositionAnimation implements ChartAnimation {
5
5
Animation <Offset >? _animation;
6
+ CurvedAnimation ? _listener;
6
7
Offset _lastPosition = Offset .zero;
7
8
8
9
ChartPositionAnimation ();
@@ -21,6 +22,7 @@ class ChartPositionAnimation implements ChartAnimation {
21
22
@override
22
23
void dispose () {
23
24
_animation = null ;
25
+ _listener? .dispose ();
24
26
}
25
27
26
28
/// Initialize animation.
@@ -31,15 +33,14 @@ class ChartPositionAnimation implements ChartAnimation {
31
33
Offset ? initialPosition,
32
34
ChartPositionAnimation ? oldAnimation,
33
35
}) {
34
- final Animation <Offset > animation = Tween <Offset >(
36
+ _listener? .dispose ();
37
+ _listener = CurvedAnimation (
38
+ parent: controller,
39
+ curve: curve,
40
+ );
41
+ _animation = Tween <Offset >(
35
42
begin: oldAnimation? ._lastPosition ?? initialPosition ?? position,
36
43
end: position,
37
- ).animate (
38
- CurvedAnimation (
39
- parent: controller,
40
- curve: curve,
41
- ),
42
- );
43
- _animation = animation;
44
+ ).animate (_listener! );
44
45
}
45
46
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ part of 'chart_animation.dart';
3
3
/// Provides size animation values.
4
4
class ChartSizeAnimation implements ChartAnimation {
5
5
Animation <Size >? _animation;
6
+ CurvedAnimation ? _listener;
6
7
Size _lastSize = Size .zero;
7
8
8
9
ChartSizeAnimation ();
@@ -21,6 +22,7 @@ class ChartSizeAnimation implements ChartAnimation {
21
22
@override
22
23
void dispose () {
23
24
_animation = null ;
25
+ _listener? .dispose ();
24
26
}
25
27
26
28
/// Initialize animation.
@@ -31,15 +33,14 @@ class ChartSizeAnimation implements ChartAnimation {
31
33
Size ? initialSize,
32
34
ChartSizeAnimation ? oldAnimation,
33
35
}) {
34
- final Animation <Size > animation = Tween <Size >(
36
+ _listener? .dispose ();
37
+ _listener = CurvedAnimation (
38
+ parent: controller,
39
+ curve: curve,
40
+ );
41
+ _animation = Tween <Size >(
35
42
begin: oldAnimation? ._lastSize ?? initialSize ?? size,
36
43
end: size,
37
- ).animate (
38
- CurvedAnimation (
39
- parent: controller,
40
- curve: curve,
41
- ),
42
- );
43
- _animation = animation;
44
+ ).animate (_listener! );
44
45
}
45
46
}
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ part of 'chart_animation.dart';
3
3
/// Provides text style animation values.
4
4
class ChartTextStyleAnimation implements ChartAnimation {
5
5
Animation <TextStyle >? _animation;
6
+ CurvedAnimation ? _listener;
7
+
6
8
TextStyle _lastTextStyle = const TextStyle (
7
9
color: Colors .transparent,
8
10
);
@@ -26,6 +28,7 @@ class ChartTextStyleAnimation implements ChartAnimation {
26
28
@override
27
29
void dispose () {
28
30
_animation = null ;
31
+ _listener? .dispose ();
29
32
}
30
33
31
34
/// Initialize animation.
@@ -36,19 +39,18 @@ class ChartTextStyleAnimation implements ChartAnimation {
36
39
TextStyle ? initialTextSyle,
37
40
ChartTextStyleAnimation ? oldAnimation,
38
41
}) {
39
- final Animation <TextStyle > animation = TextStyleTween (
42
+ _listener? .dispose ();
43
+ _listener = CurvedAnimation (
44
+ parent: controller,
45
+ curve: curve,
46
+ );
47
+ _animation = TextStyleTween (
40
48
begin: oldAnimation? ._lastTextStyle ??
41
49
initialTextSyle ??
42
50
const TextStyle (
43
51
color: Colors .transparent,
44
52
),
45
53
end: textStyle,
46
- ).animate (
47
- CurvedAnimation (
48
- parent: controller,
49
- curve: curve,
50
- ),
51
- );
52
- _animation = animation;
54
+ ).animate (_listener! );
53
55
}
54
56
}
You can’t perform that action at this time.
0 commit comments