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
First of all, great package. After some research yours is the only package that supports positive and negative ListView, which should really be a default behaviour in flutter but I digress.
I noticed the following issues:
The animateTo() method is not forwarding the duration and curve parameter to the animateToIndexAndOffset() method. I've had to override this controller to be able to use it effectively with duration and curve.
It took me a lot of hours to try and get a snapping behaviour to work, mainly because of the confusion around the animateToIndex() method. Finally, after hours of frustration, and testing, the animatetToIndex does not really do what the name suggest. It only animates back to an anchor point known as the _originIndex, and jumps each time a new index is called. So I abandoned its usage and tried other methods. May I suggest that it is renamed to animateToAnchor(). This would make it more clear. If developer wants to jump to a specific index, they could just use jumpTo() instead. Baking in a use case for jumping to an index in an "animate" method is confusing.
I ended up using the animateToWithSameOriginIndex() method to achieve what I thought animateToIndex would achieve. I feel like this should have been named animateTo() though because it actually does the animation since the origin does not change. The animateTo() should really be renamed to jumpOrAnimateToAnchor() because it really only animates if the anchor hasn't changed from a previous programatic jump.
Overall, I just think the explicit use of the word jump and animate to do what they are suppose to do will make it less confusing.
May I suggest the change in the name of _originIndex to _anchorIndex as anchor seems to be more meaningful to understand the purpose of the index.
Wrapping the IndexedListView with a NotificationListener to listen for scroll events seem to clash with the animation/jump method. To overcome this issue I had to delay the call to the animation code. See below:
if (scrollInfo is ScrollEndNotification) {
if (widget.controller.offset != itemStartLocation) {
// Controller will only register the animation after a short delay
Future.delayed(
const Duration(milliseconds: 1),
() => widget.controller.animateToWithSameOriginIndex(itemStartLocation, duration: widget.snappingSpeed, curve: widget.animationCurve),
);
}
}
Sorry for the long post, but I do think that this is a really great package and I want it to gain more popularity and should really be adopted as part of the flutter SDK.
The text was updated successfully, but these errors were encountered:
I have fixed your item (1) above in indexed_list_view: ^2.0.2.
Regarding the name change suggestions, while I agree with most of your suggestions, these would all be breaking changes and would force every single person using this lib to change names. So I decided not to touch those.
I believe negative indexes and jump/animate to index methods should be part of the Flutter SDK scrollables; but as this package itself was created simply as a proof of concept during discussions with the Flutter team and other people about the lack of a jumpToIndex method in the ListView and other scrollables.
First of all, great package. After some research yours is the only package that supports positive and negative ListView, which should really be a default behaviour in flutter but I digress.
I noticed the following issues:
Sorry for the long post, but I do think that this is a really great package and I want it to gain more popularity and should really be adopted as part of the flutter SDK.
The text was updated successfully, but these errors were encountered: