quire-io/scroll-to-index

How to get current list item Index on scroll?

imSanjaySoni opened this issue · 4 comments

How to get current list item Index on scroll?

dup of #40

 scroll_to_index: ^1.0.0
void listenPosition() {
  scrollController.addListener(() {
    final int currentIndex = scrollController.currentTagIndexInViewport(
        preferPosition: AutoScrollPosition.begin);
    AutoScrollTagState asts = scrollController.tagMap[currentIndex];
  });
}

Error:

A value of type 'dynamic' can't be assigned to a variable of type 'int'.
Try changing the type of the variable, or casting the right-hand type to 'int'.dart(invalid_assignment)
The method 'currentTagIndexInViewport' isn't defined for the type 'AutoScrollController'.
Try correcting the name to the name of an existing method, or defining a method named 'currentTagIndexInViewport'.dart(undefined_method)

try this way. flutter/flutter#19941 (comment)

@jerrywell could you please explain this in simpler way. I am not getting it, or can you tag other example.