CupertinoDatePicker constructor

CupertinoDatePicker({CupertinoDatePickerMode mode: CupertinoDatePickerMode.dateAndTime, @required ValueChanged<DateTime> onDateTimeChanged, DateTime initialDateTime, DateTime minimumDate, DateTime maximumDate, int minimumYear: 1, int maximumYear, int minuteInterval: 1, bool use24hFormat: false })

Constructs an iOS style date picker.

mode is one of the mode listed in CupertinoDatePickerMode and defaults to CupertinoDatePickerMode.dateAndTime.

onDateTimeChanged is the callback called when the selected date or time changes and must not be null.

initialDateTime is the initial date time of the picker. Defaults to the present date and time and must not be null. The present must conform to the intervals set in minimumDate, maximumDate, minimumYear, and maximumYear.

minimumDate is the minimum date that the picker can be scrolled to in CupertinoDatePickerMode.dateAndTime mode. Null if there's no limit.

maximumDate is the maximum date that the picker can be scrolled to in CupertinoDatePickerMode.dateAndTime mode. Null if there's no limit.

minimumYear is the minimum year that the picker can be scrolled to in CupertinoDatePickerMode.date mode. Defaults to 1 and must not be null.

maximumYear is the maximum year that the picker can be scrolled to in CupertinoDatePickerMode.date mode. Null if there's no limit.

minuteInterval is the granularity of the minute spinner. Must be a positive integer factor of 60.

use24hFormat decides whether 24 hour format is used. Defaults to false.

Implementation

CupertinoDatePicker({
  this.mode = CupertinoDatePickerMode.dateAndTime,
  @required this.onDateTimeChanged,
  // ignore: always_require_non_null_named_parameters
  DateTime initialDateTime,
  this.minimumDate,
  this.maximumDate,
  this.minimumYear = 1,
  this.maximumYear,
  this.minuteInterval = 1,
  this.use24hFormat = false,
}) : initialDateTime = initialDateTime ?? DateTime.now(),
     assert(mode != null),
     assert(onDateTimeChanged != null),
     assert(initialDateTime != null),
     assert(
       mode != CupertinoDatePickerMode.dateAndTime || minimumDate == null || !initialDateTime.isBefore(minimumDate),
       'initial date is before minimum date',
     ),
     assert(
       mode != CupertinoDatePickerMode.dateAndTime || maximumDate == null || !initialDateTime.isAfter(maximumDate),
       'initial date is after maximum date',
     ),
     assert(minimumYear != null),
     assert(
       mode != CupertinoDatePickerMode.date || (minimumYear >= 1 && initialDateTime.year >= minimumYear),
       'initial year is not greater than minimum year, or mininum year is not positive',
     ),
     assert(
       mode != CupertinoDatePickerMode.date || maximumYear == null || initialDateTime.year <= maximumYear,
       'initial year is not smaller than maximum year',
     ),
     assert(
       minuteInterval > 0 && 60 % minuteInterval == 0,
       'minute interval is not a positive integer factor of 60',
     ),
     assert(
       initialDateTime.minute % minuteInterval == 0,
       'initial minute is not divisible by minute interval',
     );