CupertinoPicker.builder constructor Null safety
- {Key? key,
- double diameterRatio = _kDefaultDiameterRatio,
- Color? backgroundColor,
- double offAxisFraction = 0.0,
- bool useMagnifier = false,
- double magnification = 1.0,
- FixedExtentScrollController? scrollController,
- double squeeze = _kSqueeze,
- required double itemExtent,
- required ValueChanged<
int> ? onSelectedItemChanged, - required NullableIndexedWidgetBuilder itemBuilder,
- int? childCount,
- Widget? selectionOverlay = const CupertinoPickerDefaultSelectionOverlay()}
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 null, which disables background painting entirely. (i.e. the picker is going to have a completely transparent background), to match the native UIPicker and UIDatePicker.
Implementation
CupertinoPicker.builder({
super.key,
this.diameterRatio = _kDefaultDiameterRatio,
this.backgroundColor,
this.offAxisFraction = 0.0,
this.useMagnifier = false,
this.magnification = 1.0,
this.scrollController,
this.squeeze = _kSqueeze,
required this.itemExtent,
required this.onSelectedItemChanged,
required NullableIndexedWidgetBuilder itemBuilder,
int? childCount,
this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
}) : assert(itemBuilder != null),
assert(diameterRatio != null),
assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(magnification > 0),
assert(itemExtent != null),
assert(itemExtent > 0),
assert(squeeze != null),
assert(squeeze > 0),
childDelegate = ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);