ScrollPosition constructor Null safety

ScrollPosition(
  1. {required ScrollPhysics physics,
  2. required ScrollContext context,
  3. bool keepScrollOffset = true,
  4. ScrollPosition? oldPosition,
  5. String? debugLabel}
)

Creates an object that determines which portion of the content is visible in a scroll view.

The physics, context, and keepScrollOffset parameters must not be null.

Implementation

ScrollPosition({
  required this.physics,
  required this.context,
  this.keepScrollOffset = true,
  ScrollPosition? oldPosition,
  this.debugLabel,
}) : assert(physics != null),
     assert(context != null),
     assert(context.vsync != null),
     assert(keepScrollOffset != null) {
  if (oldPosition != null)
    absorb(oldPosition);
  if (keepScrollOffset)
    restoreScrollOffset();
}