SfDateRangePicker constructor

SfDateRangePicker({
  1. Key? key,
  2. DateRangePickerView view = DateRangePickerView.month,
  3. DateRangePickerSelectionMode selectionMode = DateRangePickerSelectionMode.single,
  4. double headerHeight = 40,
  5. Color? todayHighlightColor,
  6. Color? backgroundColor,
  7. DateTime? initialSelectedDate,
  8. List<DateTime>? initialSelectedDates,
  9. PickerDateRange? initialSelectedRange,
  10. List<PickerDateRange>? initialSelectedRanges,
  11. bool toggleDaySelection = false,
  12. bool enablePastDates = true,
  13. bool showNavigationArrow = false,
  14. String confirmText = 'OK',
  15. String cancelText = 'CANCEL',
  16. bool showActionButtons = false,
  17. DateRangePickerSelectionShape selectionShape = DateRangePickerSelectionShape.circle,
  18. DateRangePickerNavigationDirection navigationDirection = DateRangePickerNavigationDirection.horizontal,
  19. bool allowViewNavigation = true,
  20. DateRangePickerNavigationMode navigationMode = DateRangePickerNavigationMode.snap,
  21. bool enableMultiView = false,
  22. DateRangePickerController? controller,
  23. DateRangePickerViewChangedCallback? onViewChanged,
  24. DateRangePickerSelectionChangedCallback? onSelectionChanged,
  25. VoidCallback? onCancel,
  26. dynamic onSubmit(
    1. Object?
    )?,
  27. DateRangePickerHeaderStyle headerStyle = const DateRangePickerHeaderStyle(),
  28. DateRangePickerYearCellStyle yearCellStyle = const DateRangePickerYearCellStyle(),
  29. DateRangePickerMonthViewSettings monthViewSettings = const DateRangePickerMonthViewSettings(),
  30. DateRangePickerMonthCellStyle monthCellStyle = const DateRangePickerMonthCellStyle(),
  31. DateTime? minDate,
  32. DateTime? maxDate,
  33. DateTime? initialDisplayDate,
  34. double viewSpacing = 20,
  35. double selectionRadius = -1,
  36. Color? selectionColor,
  37. Color? startRangeSelectionColor,
  38. Color? endRangeSelectionColor,
  39. Color? rangeSelectionColor,
  40. TextStyle? selectionTextStyle,
  41. TextStyle? rangeTextStyle,
  42. String? monthFormat,
  43. DateRangePickerCellBuilder? cellBuilder,
  44. bool showTodayButton = false,
  45. DateRangePickerSelectableDayPredicate? selectableDayPredicate,
  46. ExtendableRangeSelectionDirection extendableRangeSelectionDirection = ExtendableRangeSelectionDirection.both,
})

Creates a material design date range picker.

To restrict the date navigation and selection interaction use minDate, maxDate, the dates beyond this will be restricted.

When the selected dates or ranges change, the widget will call the onSelectionChanged callback with new selected dates or ranges.

When the visible view changes, the widget will call the onViewChanged callback with the current view and the current view visible dates.

Implementation

SfDateRangePicker(
    {Key? key,
    DateRangePickerView view = DateRangePickerView.month,
    this.selectionMode = DateRangePickerSelectionMode.single,
    this.headerHeight = 40,
    this.todayHighlightColor,
    this.backgroundColor,
    DateTime? initialSelectedDate,
    List<DateTime>? initialSelectedDates,
    PickerDateRange? initialSelectedRange,
    List<PickerDateRange>? initialSelectedRanges,
    this.toggleDaySelection = false,
    this.enablePastDates = true,
    this.showNavigationArrow = false,
    this.confirmText = 'OK',
    this.cancelText = 'CANCEL',
    this.showActionButtons = false,
    this.selectionShape = DateRangePickerSelectionShape.circle,
    this.navigationDirection = DateRangePickerNavigationDirection.horizontal,
    this.allowViewNavigation = true,
    this.navigationMode = DateRangePickerNavigationMode.snap,
    this.enableMultiView = false,
    this.controller,
    this.onViewChanged,
    this.onSelectionChanged,
    this.onCancel,
    this.onSubmit,
    this.headerStyle = const DateRangePickerHeaderStyle(),
    this.yearCellStyle = const DateRangePickerYearCellStyle(),
    this.monthViewSettings = const DateRangePickerMonthViewSettings(),
    this.monthCellStyle = const DateRangePickerMonthCellStyle(),
    DateTime? minDate,
    DateTime? maxDate,
    DateTime? initialDisplayDate,
    double viewSpacing = 20,
    this.selectionRadius = -1,
    this.selectionColor,
    this.startRangeSelectionColor,
    this.endRangeSelectionColor,
    this.rangeSelectionColor,
    this.selectionTextStyle,
    this.rangeTextStyle,
    this.monthFormat,
    this.cellBuilder,
    this.showTodayButton = false,
    this.selectableDayPredicate,
    this.extendableRangeSelectionDirection =
        ExtendableRangeSelectionDirection.both})
    : assert(headerHeight >= -1),
      assert(minDate == null || maxDate == null || minDate.isBefore(maxDate)),
      assert(minDate == null || maxDate == null || maxDate.isAfter(minDate)),
      assert(viewSpacing >= 0),
      initialSelectedDate =
          controller != null && controller.selectedDate != null
              ? controller.selectedDate
              : initialSelectedDate,
      initialSelectedDates =
          controller != null && controller.selectedDates != null
              ? controller.selectedDates
              : initialSelectedDates,
      initialSelectedRange =
          controller != null && controller.selectedRange != null
              ? controller.selectedRange
              : initialSelectedRange,
      initialSelectedRanges =
          controller != null && controller.selectedRanges != null
              ? controller.selectedRanges
              : initialSelectedRanges,
      view = controller != null && controller.view != null
          ? controller.view!
          : view,
      initialDisplayDate =
          controller != null && controller.displayDate != null
              ? controller.displayDate!
              : initialDisplayDate ?? DateTime.now(),
      minDate = minDate ?? DateTime(1900),
      maxDate = maxDate ?? DateTime(2100, 12, 31),
      viewSpacing = enableMultiView ? viewSpacing : 0,
      super(key: key);