ScrollPositionWithSingleContext constructor

  1. {@required ScrollPhysics physics,
  2. @required ScrollContext context,
  3. double initialPixels: 0.0,
  4. bool keepScrollOffset: true,
  5. ScrollPosition oldPosition,
  6. String debugLabel}

Create a ScrollPosition object that manages its behavior using ScrollActivity objects.

The initialPixels argument can be null, but in that case it is imperative that the value be set, using correctPixels, as soon as applyNewDimensions is invoked, before calling the inherited implementation of that method.

If keepScrollOffset is true (the default), the current scroll offset is saved with PageStorage and restored it if this scroll position's scrollable is recreated.


  @required ScrollPhysics physics,
  @required ScrollContext context,
  double initialPixels = 0.0,
  bool keepScrollOffset = true,
  ScrollPosition oldPosition,
  String debugLabel,
}) : super(
       physics: physics,
       context: context,
       keepScrollOffset: keepScrollOffset,
       oldPosition: oldPosition,
       debugLabel: debugLabel,
     ) {
  // If oldPosition is not null, the superclass will first call absorb(),
  // which may set _pixels and _activity.
  if (pixels == null && initialPixels != null)
  if (activity == null)
  assert(activity != null);