@@ -270,6 +270,8 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
270270
271271 bool _isTransitioning = false ;
272272
273+ var _animationController;
274+
273275 @override
274276 void initState () {
275277 super .initState ();
@@ -297,6 +299,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
297299 .removeListener (_updatePositions);
298300 secondary.itemPositionsNotifier.itemPositions
299301 .removeListener (_updatePositions);
302+ _animationController? .dispose ();
300303 super .dispose ();
301304 }
302305
@@ -484,7 +487,11 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
484487 startAnimationCallback = () {
485488 SchedulerBinding .instance.addPostFrameCallback ((_) {
486489 startAnimationCallback = () {};
487-
490+ _animationController? .dispose ();
491+ _animationController =
492+ AnimationController (vsync: this , duration: duration)..forward ();
493+ opacity.parent = _opacityAnimation (opacityAnimationWeights)
494+ .animate (_animationController);
488495 opacity.parent = _opacityAnimation (opacityAnimationWeights).animate (
489496 AnimationController (vsync: this , duration: duration)..forward ());
490497 secondary.scrollController.jumpTo (- direction *
@@ -527,17 +534,19 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
527534 }
528535 }
529536
530- setState (() {
531- if (opacity.value >= 0.5 ) {
532- // Secondary [ListView] is more visible than the primary; make it the
533- // new primary.
534- var temp = primary;
535- primary = secondary;
536- secondary = temp;
537- }
538- _isTransitioning = false ;
539- opacity.parent = const AlwaysStoppedAnimation <double >(0 );
540- });
537+ if (mounted) {
538+ setState (() {
539+ if (opacity.value >= 0.5 ) {
540+ // Secondary [ListView] is more visible than the primary; make it the
541+ // new primary.
542+ var temp = primary;
543+ primary = secondary;
544+ secondary = temp;
545+ }
546+ _isTransitioning = false ;
547+ opacity.parent = const AlwaysStoppedAnimation <double >(0 );
548+ });
549+ }
541550 }
542551
543552 Animatable <double > _opacityAnimation (List <double > opacityAnimationWeights) {
0 commit comments