Skip to content
pubscout

scroll_to_index

3.0.1, released 5 years ago by quire.io

Scroll to a specific child of any scrollable widget in Flutter.

WASM-ready
$ flutter pub add scroll_to_index
Source repository

What it does

Provides a mechanism to scroll to a specific index inside any Flutter scrollable widget using an AutoScrollController and AutoScrollTag. Supports both fixed and variable row heights.

AI-written summary of version 3.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to programmatically scroll a ListView or other scrollable widget to a specific item index.
  • You want to highlight children when they are scrolled into view.

Skip it when

  • You do not need to target specific child indices programmatically in your scroll views.

Strengths

  • Works with any Flutter scrollable widget.
  • Supports both fixed and variable row heights.
  • Provides optional highlighting capabilities for targeted items.

Weaknesses

  • Requires wrapping children in AutoScrollTag widgets and using a custom controller.
  • Variable row height scrolling relies on estimation and search mechanisms.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
final controller = AutoScrollController();

ListView(
  controller: controller,
  children: List.generate(100, (index) => AutoScrollTag(
    key: ValueKey(index),
    controller: controller,
    index: index,
    child: Text('Item $index'),
  )),
);

Alternatives

Packages that do the same job and could replace scroll_to_index.

Works with

Packages commonly used together with scroll_to_index: ones it builds on, ones built on it, and its own family.