CupertinoPicker constructor Null safety

CupertinoPicker(
  1. {Key? key,
  2. double diameterRatio,
  3. Color? backgroundColor,
  4. double offAxisFraction,
  5. bool useMagnifier,
  6. double magnification,
  7. FixedExtentScrollController? scrollController,
  8. double squeeze,
  9. required double itemExtent,
  10. required ValueChanged<int>? onSelectedItemChanged,
  11. required List<Widget> children,
  12. Widget? selectionOverlay,
  13. bool looping = false}
)

Creates a picker from a concrete list of children.

The diameterRatio and itemExtent arguments must not be null. The itemExtent must be greater than zero.

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. Also, if it has transparency, no gradient effect will be rendered.

The scrollController argument can be used to specify a custom FixedExtentScrollController for programmatically reading or changing the current picker index or for selecting an initial index value.

The looping argument decides whether the child list loops and can be scrolled infinitely. If set to true, scrolling past the end of the list will loop the list back to the beginning. If set to false, the list will stop scrolling when you reach the end or the beginning.

Implementation

CupertinoPicker({
  Key? 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 List<Widget> children,
  this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
  bool looping = false,
}) : assert(children != 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 = looping
                     ? ListWheelChildLoopingListDelegate(children: children)
                     : ListWheelChildListDelegate(children: children),
     super(key: key);