createScrollPosition method

  1. @override
ScrollPosition createScrollPosition (ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition)

Creates a ScrollPosition for use by a Scrollable widget.

Subclasses can override this function to customize the ScrollPosition used by the scrollable widgets they control. For example, PageController overrides this function to return a page-oriented scroll position subclass that keeps the same page visible when the scrollable widget resizes.

By default, returns a ScrollPositionWithSingleContext.

The arguments are generally passed to the ScrollPosition being created:


ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) {
  return _FixedExtentScrollPosition(
    physics: physics,
    context: context,
    initialItem: initialItem,
    oldPosition: oldPosition,