Menu

1 / 5

scroll_to_index_list: jump or animate to any item index in a Flutter list

DEV Community: flutter·Abdeldjalil Chougui·10 days ago
#gpAHTnJO
#devtoflutter#devto#dev#list#index
Long article (1485 words) — no AI summary yet.
Reading 0:00
15s threshold

"Scroll to message 4,812" sounds like something a list should just do. In Flutter it is harder than it looks. A ListView builds its items lazily and knows the height of an item only after laying it out. To scroll to a pixel offset you need the heights of everything before the target, and with items of different heights nobody knows them until they are built.

scrollable_positioned_list solved this with an index-based API: an ItemScrollController to jump or scroll to an index, and an ItemPositionsListener to know which items are visible. The API is good. The README of this package lists what was not: scrolling to the last items could overshoot or leave blank space, controllers could trip an assertion when a list was rebuilt, and a far scroll crossfaded between two lists.

scroll_to_index_list is a Flutter list that can jump or animate to any item index and report which items are visible.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.