marcglasberg / indexed_list_view

Flutter package: Similar to a ListView, but lets you programmatically jump to any item, by index.
BSD 2-Clause "Simplified" License
251 stars 21 forks source link

RangeError (index): does indexed_list_view can only be used if the list is indefinitely? Thank you! #23

Closed lutang123 closed 4 years ago

lutang123 commented 4 years ago

Hi, I am learning how to use this widget. I replaced my ListView.builder to IndexedListView.builder and with a controller, my list only has a certain number of item, is this the reason I got this error?

my code looks like this:

IndexedListView.builder( controller: controller, itemBuilder: (context, index) { return ListTile( title: Text(_myList[index].title), );

Does this work? how can i change it?

Also when we use controller.jumpTo(index), in the example, we only have something like controller.jumpTo(21), the index is a fixed number, but if I create a button and want to click to jump to a certain item, how do I know the index of that items?

Any help appreciated. Maybe it's not really an issue here, but how to apply, thank you!

Lu

marcglasberg commented 4 years ago

Unfortunately this list is useful only when you have an infinite number of items. For example, like a calendar, that never ends. For a finite number if items I suggest you use https://pub.dev/packages/scrollable_positioned_list