ScrollPositionWithSingleContext constructor
- required ScrollPhysics physics,
- required ScrollContext context,
- double? initialPixels = 0.0,
- bool keepScrollOffset = true,
- ScrollPosition? oldPosition,
- 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.
Implementation
ScrollPositionWithSingleContext({
required super.physics,
required super.context,
double? initialPixels = 0.0,
super.keepScrollOffset,
super.oldPosition,
super.debugLabel,
}) {
// If oldPosition is not null, the superclass will first call absorb(),
// which may set _pixels and _activity.
if (!hasPixels && initialPixels != null) {
correctPixels(initialPixels);
}
if (activity == null) {
goIdle();
}
assert(activity != null);
}