NumberPicker.integer constructor

NumberPicker.integer({
  1. Key? key,
  2. required int initialValue,
  3. required int minValue,
  4. required int maxValue,
  5. required ValueChanged<num> onChanged,
  6. bool enabled = true,
  7. TextMapper? textMapper,
  8. double itemExtent = kDefaultItemExtent,
  9. double? listViewWidth = kDefaultListViewCrossAxisSize,
  10. int step = 1,
  11. Axis scrollDirection = Axis.vertical,
  12. bool zeroPad = false,
  13. bool highlightSelectedValue = true,
  14. Decoration? decoration,
  15. bool haptics = false,
  16. TextStyle? selectedRowStyle,
  17. TextStyle? unselectedRowStyle,
  18. bool? isShowMonthName = false,
  19. bool? isJalali = false,
})

constructor for integer number picker

Implementation

NumberPicker.integer({
  Key? key,
  required int initialValue,
  required this.minValue,
  required this.maxValue,
  required this.onChanged,
  this.enabled = true,
  this.textMapper,
  this.itemExtent = kDefaultItemExtent,
  this.listViewWidth = kDefaultListViewCrossAxisSize,
  this.step = 1,
  this.scrollDirection = Axis.vertical,
  this.zeroPad = false,
  this.highlightSelectedValue = true,
  this.decoration,
  this.haptics = false,
  this.selectedRowStyle,
  this.unselectedRowStyle,
  this.isShowMonthName = false,
  this.isJalali = false,
})  : assert(maxValue >= minValue),
      // assert(initialValue >= minValue && initialValue <= maxValue),
      assert(step > 0),
      selectedIntValue = (initialValue < minValue)
          ? minValue
          : ((initialValue > maxValue) ? maxValue : initialValue),
      selectedDecimalValue = -1,
      decimalPlaces = 0,
      intScrollController = ScrollController(
        initialScrollOffset: (initialValue - minValue) ~/ step * itemExtent,
      ),
      decimalScrollController = null,
      listViewHeight = 3 * itemExtent,
      integerItemCount = (maxValue - minValue) ~/ step + 1,
      super(key: key) {
  onChanged(selectedIntValue);
}