center property

Key? center
finalinherited

The first child in the GrowthDirection.forward growth direction.

Children after center will be placed in the AxisDirection determined by scrollDirection and reverse relative to the center. Children before center will be placed in the opposite of the axis direction relative to the center. This makes the center the inflection point of the growth direction.

The center must be the key of one of the slivers built by buildSlivers.

Of the built-in subclasses of ScrollView, only CustomScrollView supports center; for that class, the given key must be the key of one of the slivers in the CustomScrollView.slivers list.

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.

{@tool dartpad} 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.

** See code in examples/api/lib/rendering/growth_direction/growth_direction.0.dart ** {@end-tool}

See also:

  • anchor, which controls where the center as aligned in the viewport.

Implementation

final Key? center;