Commit 1e093701 authored by Ian Hickson's avatar Ian Hickson

Save some memory by only storing one copy of the animation object... (#3724)

Turns out we were storing the same object in the base class and the
subclass. For pretty much every AnimatedWidget subclass.
parent 7712e583
...@@ -51,10 +51,10 @@ class AnimatedModalBarrier extends AnimatedWidget { ...@@ -51,10 +51,10 @@ class AnimatedModalBarrier extends AnimatedWidget {
Key key, Key key,
Animation<Color> color, Animation<Color> color,
this.dismissable: true this.dismissable: true
}) : color = color, super(key: key, animation: color); }) : super(key: key, animation: color);
/// If non-null, fill the barrier with this color. /// If non-null, fill the barrier with this color.
final Animation<Color> color; Animation<Color> get color => animation;
/// Whether touching the barrier will pop the current route off the [Navigator]. /// Whether touching the barrier will pop the current route off the [Navigator].
final bool dismissable; final bool dismissable;
......
...@@ -88,13 +88,13 @@ class SlideTransition extends AnimatedWidget { ...@@ -88,13 +88,13 @@ class SlideTransition extends AnimatedWidget {
Animation<FractionalOffset> position, Animation<FractionalOffset> position,
this.transformHitTests: true, this.transformHitTests: true,
this.child this.child
}) : position = position, super(key: key, animation: position); }) : super(key: key, animation: position);
/// The animation that controls the position of the child. /// The animation that controls the position of the child.
/// ///
/// If the current value of the position animation is (dx, dy), the child will /// If the current value of the position animation is (dx, dy), the child will
/// be translated horizontally by width * dx and vertically by height * dy. /// be translated horizontally by width * dx and vertically by height * dy.
final Animation<FractionalOffset> position; Animation<FractionalOffset> get position => animation;
/// Whether hit testing should be affected by the slide animation. /// Whether hit testing should be affected by the slide animation.
/// ///
...@@ -128,15 +128,13 @@ class ScaleTransition extends AnimatedWidget { ...@@ -128,15 +128,13 @@ class ScaleTransition extends AnimatedWidget {
Animation<double> scale, Animation<double> scale,
this.alignment: FractionalOffset.center, this.alignment: FractionalOffset.center,
this.child this.child
}) : scale = scale, super(key: key, animation: scale) { }) : super(key: key, animation: scale);
assert(scale != null);
}
/// The animation that controls the scale of the child. /// The animation that controls the scale of the child.
/// ///
/// If the current value of the scale animation is v, the child will be /// If the current value of the scale animation is v, the child will be
/// painted v times its normal size. /// painted v times its normal size.
final Animation<double> scale; Animation<double> get scale => animation;
/// The alignment of the origin of the coordainte system in which the scale /// The alignment of the origin of the coordainte system in which the scale
/// takes place, relative to the size of the box. /// takes place, relative to the size of the box.
...@@ -170,13 +168,13 @@ class RotationTransition extends AnimatedWidget { ...@@ -170,13 +168,13 @@ class RotationTransition extends AnimatedWidget {
Key key, Key key,
Animation<double> turns, Animation<double> turns,
this.child this.child
}) : turns = turns, super(key: key, animation: turns); }) : super(key: key, animation: turns);
/// The animation that controls the rotation of the child. /// The animation that controls the rotation of the child.
/// ///
/// If the current value of the turns animation is v, the child will be /// If the current value of the turns animation is v, the child will be
/// rotated v * 2 * pi radians before being painted. /// rotated v * 2 * pi radians before being painted.
final Animation<double> turns; Animation<double> get turns => animation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
...@@ -206,7 +204,7 @@ class SizeTransition extends AnimatedWidget { ...@@ -206,7 +204,7 @@ class SizeTransition extends AnimatedWidget {
Animation<double> sizeFactor, Animation<double> sizeFactor,
this.axisAlignment: 0.5, this.axisAlignment: 0.5,
this.child this.child
}) : sizeFactor = sizeFactor, super(key: key, animation: sizeFactor) { }) : super(key: key, animation: sizeFactor) {
assert(axis != null); assert(axis != null);
} }
...@@ -216,7 +214,7 @@ class SizeTransition extends AnimatedWidget { ...@@ -216,7 +214,7 @@ class SizeTransition extends AnimatedWidget {
/// The animation that controls the (clipped) size of the child. If the current value /// The animation that controls the (clipped) size of the child. If the current value
/// of sizeFactor is v then the width or height of the widget will be its intrinsic /// of sizeFactor is v then the width or height of the widget will be its intrinsic
/// width or height multiplied by v. /// width or height multiplied by v.
final Animation<double> sizeFactor; Animation<double> get sizeFactor => animation;
/// How to align the child along the axis that sizeFactor is modifying. /// How to align the child along the axis that sizeFactor is modifying.
final double axisAlignment; final double axisAlignment;
...@@ -251,7 +249,7 @@ class FadeTransition extends AnimatedWidget { ...@@ -251,7 +249,7 @@ class FadeTransition extends AnimatedWidget {
Key key, Key key,
Animation<double> opacity, Animation<double> opacity,
this.child this.child
}) : opacity = opacity, super(key: key, animation: opacity); }) : super(key: key, animation: opacity);
/// The animation that controls the opacity of the child. /// The animation that controls the opacity of the child.
/// ///
...@@ -259,7 +257,7 @@ class FadeTransition extends AnimatedWidget { ...@@ -259,7 +257,7 @@ class FadeTransition extends AnimatedWidget {
/// painted with an opacity of v. For example, if v is 0.5, the child will be /// painted with an opacity of v. For example, if v is 0.5, the child will be
/// blended 50% with its background. Similarly, if v is 0.0, the child will be /// blended 50% with its background. Similarly, if v is 0.0, the child will be
/// completely transparent. /// completely transparent.
final Animation<double> opacity; Animation<double> get opacity => animation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
...@@ -296,12 +294,10 @@ class PositionedTransition extends AnimatedWidget { ...@@ -296,12 +294,10 @@ class PositionedTransition extends AnimatedWidget {
Key key, Key key,
Animation<RelativeRect> rect, Animation<RelativeRect> rect,
this.child this.child
}) : rect = rect, super(key: key, animation: rect) { }) : super(key: key, animation: rect);
assert(rect != null);
}
/// The animation that controls the child's size and position. /// The animation that controls the child's size and position.
final Animation<RelativeRect> rect; Animation<RelativeRect> get rect => animation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -12,9 +12,7 @@ class TestTransition extends AnimatedWidget { ...@@ -12,9 +12,7 @@ class TestTransition extends AnimatedWidget {
this.childFirstHalf, this.childFirstHalf,
this.childSecondHalf, this.childSecondHalf,
Animation<double> animation Animation<double> animation
}) : super(key: key, animation: animation) { }) : super(key: key, animation: animation);
assert(animation != null);
}
final Widget childFirstHalf; final Widget childFirstHalf;
final Widget childSecondHalf; final Widget childSecondHalf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment