SfDateRangePicker constructor
SfDateRangePicker({
- Key? key,
- DateRangePickerView view = DateRangePickerView.month,
- DateRangePickerSelectionMode selectionMode = DateRangePickerSelectionMode.single,
- double headerHeight = 40,
- Color? todayHighlightColor,
- Color? backgroundColor,
- DateTime? initialSelectedDate,
- List<
DateTime> ? initialSelectedDates, - PickerDateRange? initialSelectedRange,
- List<
PickerDateRange> ? initialSelectedRanges, - bool toggleDaySelection = false,
- bool enablePastDates = true,
- String confirmText = 'OK',
- String cancelText = 'CANCEL',
- bool showActionButtons = false,
- DateRangePickerSelectionShape selectionShape = DateRangePickerSelectionShape.circle,
- bool enableMultiView = false,
- DateRangePickerController? controller,
- DateRangePickerViewChangedCallback? onViewChanged,
- DateRangePickerSelectionChangedCallback? onSelectionChanged,
- VoidCallback? onCancel,
- dynamic onSubmit()?,
- DateRangePickerHeaderStyle headerStyle = const DateRangePickerHeaderStyle(),
- DateRangePickerYearCellStyle yearCellStyle = const DateRangePickerYearCellStyle(),
- DateRangePickerMonthViewSettings monthViewSettings = const DateRangePickerMonthViewSettings(),
- DateRangePickerMonthCellStyle monthCellStyle = const DateRangePickerMonthCellStyle(),
- DateTime? minDate,
- DateTime? maxDate,
- DateTime? initialDisplayDate,
- double viewSpacing = 20,
- double selectionRadius = -1,
- Color? selectionColor,
- Color? startRangeSelectionColor,
- Color? endRangeSelectionColor,
- Color? rangeSelectionColor,
- TextStyle? selectionTextStyle,
- TextStyle? rangeTextStyle,
- String? monthFormat,
- DateRangePickerCellBuilder? cellBuilder,
- bool showTodayButton = false,
- DateRangePickerSelectableDayPredicate? selectableDayPredicate,
- 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) ||
minDate == maxDate),
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);