jumpToIndex method

void jumpToIndex(
  1. int index, {
  2. required double itemExtent,
})

Jumps immediately to a specific item index given a fixed itemExtent in pixels.

  • if scroll direction is vertical, itemExtent is the computed height of an item in the scrollable component's children.
  • if scroll direction is horizontal, itemExtent is the computed width of an item in the scrollable component's children.

Example

final scrollController = ScrollController();
scrollController.jumpToIndex(
  5,
  itemExtent: 100.0,
);

Implementation

void jumpToIndex(
  int index, {
  required double itemExtent,
}) {
  jumpTo(index * itemExtent);
}