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