Cleanup nullability for ImplicitlyAnimatedWidgetState (#72091)
This commit is contained in:
parent
84a7a611b0
commit
6471a34de2
@ -777,8 +777,8 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ShapeBorder shape = _border!.evaluate(animation!)!;
|
final ShapeBorder shape = _border!.evaluate(animation)!;
|
||||||
final double elevation = _elevation!.evaluate(animation!);
|
final double elevation = _elevation!.evaluate(animation);
|
||||||
return PhysicalShape(
|
return PhysicalShape(
|
||||||
child: _ShapeBorderPaint(
|
child: _ShapeBorderPaint(
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
@ -792,7 +792,7 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
|
|||||||
clipBehavior: widget.clipBehavior,
|
clipBehavior: widget.clipBehavior,
|
||||||
elevation: elevation,
|
elevation: elevation,
|
||||||
color: ElevationOverlay.applyOverlay(context, widget.color, elevation),
|
color: ElevationOverlay.applyOverlay(context, widget.color, elevation),
|
||||||
shadowColor: _shadowColor!.evaluate(animation!)!,
|
shadowColor: _shadowColor!.evaluate(animation)!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Theme(
|
return Theme(
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
data: _data!.evaluate(animation!),
|
data: _data!.evaluate(animation),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ class _AnimatedFadeOutFadeInState extends ImplicitlyAnimatedWidgetState<_Animate
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateTweens() {
|
void didUpdateTweens() {
|
||||||
_placeholderOpacityAnimation = animation!.drive(TweenSequence<double>(<TweenSequenceItem<double>>[
|
_placeholderOpacityAnimation = animation.drive(TweenSequence<double>(<TweenSequenceItem<double>>[
|
||||||
TweenSequenceItem<double>(
|
TweenSequenceItem<double>(
|
||||||
tween: _placeholderOpacity!.chain(CurveTween(curve: widget.fadeOutCurve)),
|
tween: _placeholderOpacity!.chain(CurveTween(curve: widget.fadeOutCurve)),
|
||||||
weight: widget.fadeOutDuration.inMilliseconds.toDouble(),
|
weight: widget.fadeOutDuration.inMilliseconds.toDouble(),
|
||||||
@ -480,7 +480,7 @@ class _AnimatedFadeOutFadeInState extends ImplicitlyAnimatedWidgetState<_Animate
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_targetOpacityAnimation = animation!.drive(TweenSequence<double>(<TweenSequenceItem<double>>[
|
_targetOpacityAnimation = animation.drive(TweenSequence<double>(<TweenSequenceItem<double>>[
|
||||||
TweenSequenceItem<double>(
|
TweenSequenceItem<double>(
|
||||||
tween: ConstantTween<double>(0),
|
tween: ConstantTween<double>(0),
|
||||||
weight: widget.fadeOutDuration.inMilliseconds.toDouble(),
|
weight: widget.fadeOutDuration.inMilliseconds.toDouble(),
|
||||||
@ -493,7 +493,7 @@ class _AnimatedFadeOutFadeInState extends ImplicitlyAnimatedWidgetState<_Animate
|
|||||||
if (!widget.isTargetLoaded && _isValid(_placeholderOpacity!) && _isValid(_targetOpacity!)) {
|
if (!widget.isTargetLoaded && _isValid(_placeholderOpacity!) && _isValid(_targetOpacity!)) {
|
||||||
// Jump (don't fade) back to the placeholder image, so as to be ready
|
// Jump (don't fade) back to the placeholder image, so as to be ready
|
||||||
// for the full animation when the new target image becomes ready.
|
// for the full animation when the new target image becomes ready.
|
||||||
controller!.value = controller!.upperBound;
|
controller.value = controller.upperBound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,22 +352,21 @@ typedef TweenVisitor<T extends Object> = Tween<T>? Function(Tween<T>? tween, T t
|
|||||||
abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget> extends State<T> with SingleTickerProviderStateMixin<T> {
|
abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget> extends State<T> with SingleTickerProviderStateMixin<T> {
|
||||||
/// The animation controller driving this widget's implicit animations.
|
/// The animation controller driving this widget's implicit animations.
|
||||||
@protected
|
@protected
|
||||||
AnimationController? get controller => _controller;
|
AnimationController get controller => _controller;
|
||||||
AnimationController? _controller;
|
late final AnimationController _controller = AnimationController(
|
||||||
|
duration: widget.duration,
|
||||||
|
debugLabel: kDebugMode ? widget.toStringShort() : null,
|
||||||
|
vsync: this,
|
||||||
|
);
|
||||||
|
|
||||||
/// The animation driving this widget's implicit animations.
|
/// The animation driving this widget's implicit animations.
|
||||||
Animation<double>? get animation => _animation;
|
Animation<double> get animation => _animation;
|
||||||
Animation<double>? _animation;
|
late Animation<double> _animation = _createCurve();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller = AnimationController(
|
_controller.addStatusListener((AnimationStatus status) {
|
||||||
duration: widget.duration,
|
|
||||||
debugLabel: kDebugMode ? widget.toStringShort() : null,
|
|
||||||
vsync: this,
|
|
||||||
);
|
|
||||||
_controller!.addStatusListener((AnimationStatus status) {
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case AnimationStatus.completed:
|
case AnimationStatus.completed:
|
||||||
if (widget.onEnd != null)
|
if (widget.onEnd != null)
|
||||||
@ -378,7 +377,6 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
|
|||||||
case AnimationStatus.reverse:
|
case AnimationStatus.reverse:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_updateCurve();
|
|
||||||
_constructTweens();
|
_constructTweens();
|
||||||
didUpdateTweens();
|
didUpdateTweens();
|
||||||
}
|
}
|
||||||
@ -387,27 +385,27 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
|
|||||||
void didUpdateWidget(T oldWidget) {
|
void didUpdateWidget(T oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (widget.curve != oldWidget.curve)
|
if (widget.curve != oldWidget.curve)
|
||||||
_updateCurve();
|
_animation = _createCurve();
|
||||||
_controller!.duration = widget.duration;
|
_controller.duration = widget.duration;
|
||||||
if (_constructTweens()) {
|
if (_constructTweens()) {
|
||||||
forEachTween((Tween<dynamic>? tween, dynamic targetValue, TweenConstructor<dynamic> constructor) {
|
forEachTween((Tween<dynamic>? tween, dynamic targetValue, TweenConstructor<dynamic> constructor) {
|
||||||
_updateTween(tween, targetValue);
|
_updateTween(tween, targetValue);
|
||||||
return tween;
|
return tween;
|
||||||
});
|
});
|
||||||
_controller!
|
_controller
|
||||||
..value = 0.0
|
..value = 0.0
|
||||||
..forward();
|
..forward();
|
||||||
didUpdateTweens();
|
didUpdateTweens();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateCurve() {
|
CurvedAnimation _createCurve() {
|
||||||
_animation = CurvedAnimation(parent: _controller!, curve: widget.curve);
|
return CurvedAnimation(parent: _controller, curve: widget.curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller!.dispose();
|
_controller.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +417,7 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
|
|||||||
if (tween == null)
|
if (tween == null)
|
||||||
return;
|
return;
|
||||||
tween
|
tween
|
||||||
..begin = tween.evaluate(_animation!)
|
..begin = tween.evaluate(_animation)
|
||||||
..end = targetValue;
|
..end = targetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +550,7 @@ abstract class AnimatedWidgetBaseState<T extends ImplicitlyAnimatedWidget> exten
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
controller!.addListener(_handleAnimationChanged);
|
controller.addListener(_handleAnimationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleAnimationChanged() {
|
void _handleAnimationChanged() {
|
||||||
@ -776,7 +774,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final Animation<double> animation = this.animation!;
|
final Animation<double> animation = this.animation;
|
||||||
return Container(
|
return Container(
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
alignment: _alignment?.evaluate(animation),
|
alignment: _alignment?.evaluate(animation),
|
||||||
@ -907,7 +905,7 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState<AnimatedPadding> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: _padding!
|
padding: _padding!
|
||||||
.evaluate(animation!)
|
.evaluate(animation)
|
||||||
.clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity),
|
.clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
@ -1058,9 +1056,9 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState<AnimatedAlign> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Align(
|
return Align(
|
||||||
alignment: _alignment!.evaluate(animation!)!,
|
alignment: _alignment!.evaluate(animation)!,
|
||||||
heightFactor: _heightFactorTween?.evaluate(animation!),
|
heightFactor: _heightFactorTween?.evaluate(animation),
|
||||||
widthFactor: _widthFactorTween?.evaluate(animation!),
|
widthFactor: _widthFactorTween?.evaluate(animation),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1255,12 +1253,12 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState<AnimatedPositione
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
left: _left?.evaluate(animation!),
|
left: _left?.evaluate(animation),
|
||||||
top: _top?.evaluate(animation!),
|
top: _top?.evaluate(animation),
|
||||||
right: _right?.evaluate(animation!),
|
right: _right?.evaluate(animation),
|
||||||
bottom: _bottom?.evaluate(animation!),
|
bottom: _bottom?.evaluate(animation),
|
||||||
width: _width?.evaluate(animation!),
|
width: _width?.evaluate(animation),
|
||||||
height: _height?.evaluate(animation!),
|
height: _height?.evaluate(animation),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1392,12 +1390,12 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState<Animat
|
|||||||
return Positioned.directional(
|
return Positioned.directional(
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
start: _start?.evaluate(animation!),
|
start: _start?.evaluate(animation),
|
||||||
top: _top?.evaluate(animation!),
|
top: _top?.evaluate(animation),
|
||||||
end: _end?.evaluate(animation!),
|
end: _end?.evaluate(animation),
|
||||||
bottom: _bottom?.evaluate(animation!),
|
bottom: _bottom?.evaluate(animation),
|
||||||
width: _width?.evaluate(animation!),
|
width: _width?.evaluate(animation),
|
||||||
height: _height?.evaluate(animation!),
|
height: _height?.evaluate(animation),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1529,7 +1527,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState<AnimatedOpacit
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateTweens() {
|
void didUpdateTweens() {
|
||||||
_opacityAnimation = animation!.drive(_opacity!);
|
_opacityAnimation = animation.drive(_opacity!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1662,7 +1660,7 @@ class _SliverAnimatedOpacityState extends ImplicitlyAnimatedWidgetState<SliverAn
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateTweens() {
|
void didUpdateTweens() {
|
||||||
_opacityAnimation = animation!.drive(_opacity!);
|
_opacityAnimation = animation.drive(_opacity!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1792,7 +1790,7 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState<AnimatedDef
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultTextStyle(
|
return DefaultTextStyle(
|
||||||
style: _style!.evaluate(animation!),
|
style: _style!.evaluate(animation),
|
||||||
textAlign: widget.textAlign,
|
textAlign: widget.textAlign,
|
||||||
softWrap: widget.softWrap,
|
softWrap: widget.softWrap,
|
||||||
overflow: widget.overflow,
|
overflow: widget.overflow,
|
||||||
@ -1925,11 +1923,11 @@ class _AnimatedPhysicalModelState extends AnimatedWidgetBaseState<AnimatedPhysic
|
|||||||
child: widget.child,
|
child: widget.child,
|
||||||
shape: widget.shape,
|
shape: widget.shape,
|
||||||
clipBehavior: widget.clipBehavior,
|
clipBehavior: widget.clipBehavior,
|
||||||
borderRadius: _borderRadius!.evaluate(animation!),
|
borderRadius: _borderRadius!.evaluate(animation),
|
||||||
elevation: _elevation!.evaluate(animation!),
|
elevation: _elevation!.evaluate(animation),
|
||||||
color: widget.animateColor ? _color!.evaluate(animation!)! : widget.color,
|
color: widget.animateColor ? _color!.evaluate(animation)! : widget.color,
|
||||||
shadowColor: widget.animateShadowColor
|
shadowColor: widget.animateShadowColor
|
||||||
? _shadowColor!.evaluate(animation!)!
|
? _shadowColor!.evaluate(animation)!
|
||||||
: widget.shadowColor,
|
: widget.shadowColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ class _TweenAnimationBuilderState<T extends Object> extends AnimatedWidgetBaseSt
|
|||||||
_currentTween!.begin ??= _currentTween!.end;
|
_currentTween!.begin ??= _currentTween!.end;
|
||||||
super.initState();
|
super.initState();
|
||||||
if (_currentTween!.begin != _currentTween!.end) {
|
if (_currentTween!.begin != _currentTween!.end) {
|
||||||
controller!.forward();
|
controller.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +221,6 @@ class _TweenAnimationBuilderState<T extends Object> extends AnimatedWidgetBaseSt
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return widget.builder(context, _currentTween!.evaluate(animation!), widget.child);
|
return widget.builder(context, _currentTween!.evaluate(animation), widget.child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user