DatePicker constructor

DatePicker({
  1. Key? key,
  2. required DateTime? selected,
  3. ValueChanged<DateTime>? onChanged,
  4. VoidCallback? onCancel,
  5. String? header,
  6. TextStyle? headerStyle,
  7. bool showDay = true,
  8. bool showMonth = true,
  9. bool showYear = true,
  10. DateTime? startDate,
  11. DateTime? endDate,
  12. EdgeInsetsGeometry contentPadding = kPickerContentPadding,
  13. double popupHeight = kPickerPopupHeight,
  14. FocusNode? focusNode,
  15. bool autofocus = false,
  16. Locale? locale,
  17. List<DatePickerField>? fieldOrder,
  18. List<int>? fieldFlex,
})

Creates a date picker.

Implementation

DatePicker({
  super.key,
  required this.selected,
  this.onChanged,
  this.onCancel,
  this.header,
  this.headerStyle,
  this.showDay = true,
  this.showMonth = true,
  this.showYear = true,
  DateTime? startDate,
  DateTime? endDate,
  this.contentPadding = kPickerContentPadding,
  this.popupHeight = kPickerPopupHeight,
  this.focusNode,
  this.autofocus = false,
  this.locale,
  this.fieldOrder,
  this.fieldFlex,
})  : startDate = startDate ?? DateTime.now().subtract(kYearDuration * 100),
      endDate = endDate ?? DateTime.now().add(kYearDuration * 25),
      assert(
        fieldFlex == null || fieldFlex.length == 3,
        'fieldFlex must be null or have a length of 3',
      );