diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index 035c603bc8..e9923126c8 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -28,6 +28,9 @@ class _AlwaysCompleteAnimation extends Animation { @override double get value => 1.0; + + @override + String toString() => 'kAlwaysCompleteAnimation'; } /// An animation that is always complete. @@ -57,6 +60,9 @@ class _AlwaysDismissedAnimation extends Animation { @override double get value => 0.0; + + @override + String toString() => 'kAlwaysDismissedAnimation'; } /// An animation that is always dismissed. @@ -96,6 +102,11 @@ class AlwaysStoppedAnimation extends Animation { @override AnimationStatus get status => AnimationStatus.forward; + + @override + String toStringDetails() { + return '${super.toStringDetails()} $value; paused'; + } } /// Implements most of the [Animation] interface, by deferring its behavior to a @@ -195,6 +206,13 @@ class ProxyAnimation extends Animation @override double get value => _parent != null ? _parent.value : _value; + + @override + String toString() { + if (parent == null) + return '$runtimeType(null; ${super.toStringDetails()} ${value.toStringAsFixed(3)})'; + return '$parent\u27A9$runtimeType'; + } } /// An animation that is the reverse of another animation. @@ -251,6 +269,11 @@ class ReverseAnimation extends Animation case AnimationStatus.dismissed: return AnimationStatus.completed; } } + + @override + String toString() { + return '$parent\u27AA$runtimeType'; + } } /// An animation that applies a curve to another animation. @@ -317,10 +340,13 @@ class CurvedAnimation extends Animation with AnimationWithParentMixin with AnimationWithParentMixin _nextTrain = null; } } + + @override + String toString() { + if (_nextTrain != null) + return '$currentTrain\u27A9$runtimeType(next: $_nextTrain)'; + return '$currentTrain\u27A9$runtimeType(no next)'; + } } diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index e212e3e132..d6c5f9bef2 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -28,6 +28,11 @@ abstract class Curve { /// Returns a new curve that is the reversed inversion of this one. /// This is often useful as the reverseCurve of an [Animation]. Curve get flipped => new FlippedCurve(this); + + @override + String toString() { + return '$runtimeType'; + } } /// The identity map over the unit interval. @@ -49,6 +54,11 @@ class SawTooth extends Curve { t *= count; return t - t.truncateToDouble(); } + + @override + String toString() { + return '$runtimeType($count)'; + } } /// A curve that is 0.0 until start, then curved from 0.0 to 1.0 at end, then 1.0. @@ -76,6 +86,13 @@ class Interval extends Curve { return t; return curve.transform(t); } + + @override + String toString() { + if (curve is! Linear) + return '$runtimeType($start\u22EF$end)\u27A9$curve'; + return '$runtimeType($start\u22EF$end)'; + } } /// A cubic polynomial mapping of the unit interval. @@ -102,6 +119,11 @@ class Cubic extends Curve { end = midpoint; } } + + @override + String toString() { + return '$runtimeType(${a.toStringAsFixed(2)}, ${b.toStringAsFixed(2)}, ${c.toStringAsFixed(2)}, ${d.toStringAsFixed(2)})'; + } } double _bounce(double t) { @@ -126,6 +148,11 @@ class FlippedCurve extends Curve { @override double transform(double t) => 1.0 - curve.transform(1.0 - t); + + @override + String toString() { + return '$runtimeType($curve)'; + } } /// An oscillating curve that grows in magnitude. @@ -173,6 +200,11 @@ class ElasticInCurve extends Curve { t = t - 1.0; return -math.pow(2.0, 10.0 * t) * math.sin((t - s) * (math.PI * 2.0) / period); } + + @override + String toString() { + return '$runtimeType($period)'; + } } /// An oscillating curve that shrinks in magnitude while overshooting its bounds. @@ -186,6 +218,11 @@ class ElasticOutCurve extends Curve { double s = period / 4.0; return math.pow(2.0, -10 * t) * math.sin((t - s) * (math.PI * 2.0) / period) + 1.0; } + + @override + String toString() { + return '$runtimeType($period)'; + } } /// An oscillating curve that grows and then shrinks in magnitude while overshooting its bounds. @@ -203,6 +240,11 @@ class ElasticInOutCurve extends Curve { else return math.pow(2.0, -10.0 * t) * math.sin((t - s) * (math.PI * 2.0) / period) * 0.5 + 1.0; } + + @override + String toString() { + return '$runtimeType($period)'; + } } /// A collection of common animation curves. diff --git a/packages/flutter/lib/src/animation/tween.dart b/packages/flutter/lib/src/animation/tween.dart index 142eaf43ca..3606528844 100644 --- a/packages/flutter/lib/src/animation/tween.dart +++ b/packages/flutter/lib/src/animation/tween.dart @@ -33,7 +33,6 @@ abstract class Animatable { class _AnimatedEvaluation extends Animation with AnimationWithParentMixin { _AnimatedEvaluation(this.parent, this._evaluatable); - /// The animation from which this value is derived. @override final Animation parent; @@ -41,6 +40,16 @@ class _AnimatedEvaluation extends Animation with AnimationWithParentMixin< @override T get value => _evaluatable.evaluate(parent); + + @override + String toString() { + return '$parent\u27A9$_evaluatable'; + } + + @override + String toStringDetails() { + return '${super.toStringDetails()} $_evaluatable'; + } } class _ChainedEvaluation extends Animatable { @@ -54,6 +63,11 @@ class _ChainedEvaluation extends Animatable { double value = _parent.evaluate(animation); return _evaluatable.evaluate(new AlwaysStoppedAnimation(value)); } + + @override + String toString() { + return '$_parent\u27A9$_evaluatable'; + } } /// A linear interpolation between a beginning and ending value.