diff --git a/lib/src/core/photo_view_core.dart b/lib/src/core/photo_view_core.dart index 74595dfb..96fa5722 100644 --- a/lib/src/core/photo_view_core.dart +++ b/lib/src/core/photo_view_core.dart @@ -108,14 +108,10 @@ class PhotoViewCoreState extends State double? _scaleBefore; double? _rotationBefore; - late final AnimationController _scaleAnimationController = - AnimationController(vsync: this) - ..addListener(handleScaleAnimation) - ..addStatusListener(onAnimationStatus); + late final AnimationController _scaleAnimationController; Animation? _scaleAnimation; - late final AnimationController _positionAnimationController = - AnimationController(vsync: this)..addListener(handlePositionAnimate); + late final AnimationController _positionAnimationController; Animation? _positionAnimation; late final AnimationController _rotationAnimationController = @@ -261,6 +257,12 @@ class PhotoViewCoreState extends State addAnimateOnScaleStateUpdate(animateOnScaleStateUpdate); cachedScaleBoundaries = widget.scaleBoundaries; + + _scaleAnimationController = AnimationController(vsync: this) + ..addListener(handleScaleAnimation) + ..addStatusListener(onAnimationStatus); + _positionAnimationController = AnimationController(vsync: this) + ..addListener(handlePositionAnimate); } void animateOnScaleStateUpdate(double prevScale, double nextScale) {