Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/scrollable_positioned_list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.3.4
* Disposed the animation controller when disposing the scrollable list.

# 0.3.3
* Fix potential crash when reading from RenderBox.size.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>

bool _isTransitioning = false;

var _animationController;

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -297,6 +299,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
.removeListener(_updatePositions);
secondary.itemPositionsNotifier.itemPositions
.removeListener(_updatePositions);
_animationController?.dispose();
super.dispose();
}

Expand Down Expand Up @@ -484,7 +487,11 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
startAnimationCallback = () {
SchedulerBinding.instance.addPostFrameCallback((_) {
startAnimationCallback = () {};

_animationController?.dispose();
_animationController =
AnimationController(vsync: this, duration: duration)..forward();
opacity.parent = _opacityAnimation(opacityAnimationWeights)
.animate(_animationController);
opacity.parent = _opacityAnimation(opacityAnimationWeights).animate(
AnimationController(vsync: this, duration: duration)..forward());
secondary.scrollController.jumpTo(-direction *
Expand Down Expand Up @@ -527,17 +534,19 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
}
}

setState(() {
if (opacity.value >= 0.5) {
// Secondary [ListView] is more visible than the primary; make it the
// new primary.
var temp = primary;
primary = secondary;
secondary = temp;
}
_isTransitioning = false;
opacity.parent = const AlwaysStoppedAnimation<double>(0);
});
if (mounted) {
setState(() {
if (opacity.value >= 0.5) {
// Secondary [ListView] is more visible than the primary; make it the
// new primary.
var temp = primary;
primary = secondary;
secondary = temp;
}
_isTransitioning = false;
opacity.parent = const AlwaysStoppedAnimation<double>(0);
});
}
}

Animatable<double> _opacityAnimation(List<double> opacityAnimationWeights) {
Expand Down
2 changes: 1 addition & 1 deletion packages/scrollable_positioned_list/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: scrollable_positioned_list
version: 0.3.3
version: 0.3.4
description: >
A list with helper methods to programmatically scroll to an item.
homepage: https://github.com/google/flutter.widgets/tree/master/packages/scrollable_positioned_list
Expand Down