@@ -299,6 +299,8 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
299
299
void _speedupClosureSecondary () =>
300
300
_speedUpScrollListener (secondary.scrollController);
301
301
302
+ var _animationController;
303
+
302
304
@override
303
305
void initState () {
304
306
super .initState ();
@@ -330,6 +332,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
330
332
.removeListener (_updatePositions);
331
333
primary.scrollController.removeListener (_speedupClosurePrimary);
332
334
secondary.scrollController.removeListener (_speedupClosureSecondary);
335
+ _animationController? .dispose ();
333
336
super .dispose ();
334
337
}
335
338
@@ -526,9 +529,11 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
526
529
startAnimationCallback = () {
527
530
SchedulerBinding .instance.addPostFrameCallback ((_) {
528
531
startAnimationCallback = () {};
529
-
530
- opacity.parent = _opacityAnimation (opacityAnimationWeights).animate (
531
- AnimationController (vsync: this , duration: duration)..forward ());
532
+ _animationController? .dispose ();
533
+ _animationController =
534
+ AnimationController (vsync: this , duration: duration)..forward ();
535
+ opacity.parent = _opacityAnimation (opacityAnimationWeights)
536
+ .animate (_animationController);
532
537
secondary.scrollController.jumpTo (- direction *
533
538
(_screenScrollCount *
534
539
primary.scrollController.position.viewportDimension -
@@ -584,6 +589,19 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
584
589
_isTransitioning = false ;
585
590
opacity.parent = const AlwaysStoppedAnimation <double >(0 );
586
591
});
592
+ if (mounted) {
593
+ setState (() {
594
+ if (opacity.value >= 0.5 ) {
595
+ // Secondary [ListView] is more visible than the primary; make it the
596
+ // new primary.
597
+ var temp = primary;
598
+ primary = secondary;
599
+ secondary = temp;
600
+ }
601
+ _isTransitioning = false ;
602
+ opacity.parent = const AlwaysStoppedAnimation <double >(0 );
603
+ });
604
+ }
587
605
}
588
606
589
607
Animatable <double > _opacityAnimation (List <double > opacityAnimationWeights) {
0 commit comments