scrollByIndex method

Future<bool> scrollByIndex(
  1. int index, {
  2. bool animated = true,
  3. Duration duration = const Duration(milliseconds: 250),
  4. double? alignment,
})

Scrolls this ListView until the item at index is visible.

This is designed for lazily-built lists where the total scroll extent can't be known up front. For the last item (index == childNodes.length - 1), this will repeatedly scroll to the current maxScrollExtent until the end stabilizes.

Implementation

Future<bool> scrollByIndex(
  int index, {
  bool animated = true,
  Duration duration = const Duration(milliseconds: 250),
  double? alignment,
}) async {
  final WebFListViewState? currentState = state;
  if (currentState == null) return false;
  return await currentState.scrollByIndex(
    index,
    animated: animated,
    duration: duration,
    alignment: alignment,
  );
}