Change type in ImplicitlyAnimatedWidget to remove type cast to improve performance and style (#111849)

This commit is contained in:
fzyzcjy
2022-10-14 01:57:13 +08:00
committed by GitHub
parent b68c69aa2e
commit 50b1960a3a

View File

@@ -360,7 +360,7 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
/// The animation driving this widget's implicit animations.
Animation<double> get animation => _animation;
late Animation<double> _animation = _createCurve();
late CurvedAnimation _animation = _createCurve();
@override
void initState() {
@@ -383,7 +383,7 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
void didUpdateWidget(T oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.curve != oldWidget.curve) {
(_animation as CurvedAnimation).dispose();
_animation.dispose();
_animation = _createCurve();
}
_controller.duration = widget.duration;
@@ -405,7 +405,7 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
@override
void dispose() {
(_animation as CurvedAnimation).dispose();
_animation.dispose();
_controller.dispose();
super.dispose();
}