You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
slymnyg
changed the title
[]package - first and last index swap after fast scrolling
[scrollable_positioned_list] package - first and last index swap after fast scrolling
Sep 20, 2024
i found solution to resolved this issue, just add line VisibilityDetectorController.instance.updateInterval = Duration.zero;
It was mentioned in the document, but I missed it
final positions = itemPositionsListener.itemPositions.value.toList();
positions.sort((a, b) => a.index.compareTo(b.index));
my case is almost the same. this code solved my problem you should try it
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
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:
ScreenRecording_09-20-2024.16-05-45_1.MP4
The text was updated successfully, but these errors were encountered: