anchor property
The relative position of the zero scroll offset.
For example, if anchor is 0.5 and the axisDirection is AxisDirection.down or AxisDirection.up, then the zero scroll offset is vertically centered within the viewport. If the anchor is 1.0, and the axisDirection is AxisDirection.right, then the zero scroll offset is on the left edge of the viewport.
Most scroll views by default are ordered GrowthDirection.forward. Changing the default values of ScrollView.anchor, ScrollView.center, or both, can configure a scroll view for GrowthDirection.reverse.
This sample shows a CustomScrollView, with Radio buttons in the
AppBar.bottom that change the AxisDirection to illustrate different
configurations. The CustomScrollView.anchor and CustomScrollView.center
properties are also set to have the 0 scroll offset positioned in the middle
of the viewport, with GrowthDirection.forward and GrowthDirection.reverse
illustrated on either side. The sliver that shares the
CustomScrollView.center key is positioned at the CustomScrollView.anchor.
link
To create a local project with this code sample, run:
flutter create --sample=rendering.GrowthDirection.1 mysample
Implementation
double get anchor => _anchor;
Implementation
set anchor(double value) {
assert(value >= 0.0 && value <= 1.0);
if (value == _anchor) {
return;
}
_anchor = value;
markNeedsLayout();
}