Picker.builder constructor
Picker.builder({
- Key? key,
- double diameterRatio = _kDefaultDiameterRatio,
- Color backgroundColor = _kDefaultBackground,
- Color? lineColor = _kHighlighterBorder,
- double offAxisFraction = 0.0,
- bool useMagnifier = false,
- double magnification = 1.0,
- FixedExtentScrollController? scrollController,
- double squeeze = _kSqueeze,
- required double itemExtent,
- required ValueChanged<
int> onSelectedItemChanged, - required IndexedWidgetBuilder itemBuilder,
- int? childCount,
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
.
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
Picker.builder({
Key? key,
this.diameterRatio = _kDefaultDiameterRatio,
this.backgroundColor = _kDefaultBackground,
this.lineColor = _kHighlighterBorder,
this.offAxisFraction = 0.0,
this.useMagnifier = false,
this.magnification = 1.0,
this.scrollController,
this.squeeze = _kSqueeze,
required this.itemExtent,
required this.onSelectedItemChanged,
required IndexedWidgetBuilder itemBuilder,
int? childCount,
}) : assert(diameterRatio > 0.0,
RenderListWheelViewport.diameterRatioZeroMessage),
assert(magnification > 0),
assert(itemExtent > 0),
assert(squeeze > 0),
childDelegate = ListWheelChildBuilderDelegate(
builder: itemBuilder, childCount: childCount),
super(key: key);