-
Notifications
You must be signed in to change notification settings - Fork 523
Description
Problem description
The issue is with the scrollable_positioned_list package. I am using it to get the first and last visible item indexes in the list, but there is a problem where these indexes are swapped after fast scrolling.
Steps to reproduce
- Use the scrollable_positioned_list package in a Flutter app.
- Set up a listener for itemPositionsListener.itemPositions to track first and last indexes and log them to the console as follows:
itemPositionsListener.itemPositions.addListener(() async {
final positions = itemPositionsListener.itemPositions.value;
if (positions.isEmpty) {
return;
}
final newFirstIndex = positions.first.index;
final newLastIndex = positions.last.index;
print('First index: $newFirstIndex, Last index: $newLastIndex');
});
- Scroll the list slowly in one direction.
- Quickly scroll back up.
- Check the console log to observe that the first index and last index are swapped after fast scrolling.
The issue occurs consistently when performing these steps.
Expected behavior
The first index should represent the first visible item at the top of the screen, and the last index should represent the last visible item at the bottom.
Actual behavior
After quickly scrolling back up, the first index displays the index of the last item at the bottom of the screen, and the last index shows the index of the first item at the top of the screen. This persists until the indexes equalize, after which it works correctly again.
Environment
scrollable_positioned_list : ^0.3.8
flutter: 3.24.2
Video Demonstration: