CupertinoPicker.builder constructor
Creates a picker from an IndexedWidgetBuilder callback where the builder is dynamically invoked during layout.
A child is lazily created when it starts becoming visible in the viewport. All of the children provided by the builder are cached and reused, so normally the builder is only called once for each index (except when rebuilding - the cache is cleared).
The itemBuilder
argument must not be null. The childCount
argument
reflects the number of children that will be provided by the itemBuilder
.
If non-null, childCount
is the maximum number of children that can be
provided, and children are available from 0 to childCount
- 1.
If null, then the lower and upper limit are not known. However the builder must provide children for a contiguous segment. If the builder returns null at some index, the segment terminates there.
The itemExtent
argument must be non-null and positive.
The backgroundColor
defaults to light gray. It can be set to null to
disable the background painting entirely; this is mildly more efficient
than using Colors.transparent.
Implementation
CupertinoPicker.builder({
Key key,
this.diameterRatio = _kDefaultDiameterRatio,
this.backgroundColor = _kDefaultBackground,
this.offAxisFraction = 0.0,
this.useMagnifier = false,
this.magnification = 1.0,
this.scrollController,
@required this.itemExtent,
@required this.onSelectedItemChanged,
@required IndexedWidgetBuilder itemBuilder,
int childCount,
}) : assert(itemBuilder != null),
assert(diameterRatio != null),
assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(magnification > 0),
assert(itemExtent != null),
assert(itemExtent > 0),
childDelegate = ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount),
super(key: key);