Picker.builder constructor

Picker.builder({
  1. Key? key,
  2. double diameterRatio = _kDefaultDiameterRatio,
  3. Color backgroundColor = _kDefaultBackground,
  4. Color? lineColor = _kHighlighterBorder,
  5. double offAxisFraction = 0.0,
  6. bool useMagnifier = false,
  7. double magnification = 1.0,
  8. FixedExtentScrollController? scrollController,
  9. double squeeze = _kSqueeze,
  10. required double itemExtent,
  11. required ValueChanged<int> onSelectedItemChanged,
  12. required IndexedWidgetBuilder itemBuilder,
  13. 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);