onSubmit property
Called whenever the confirm button tapped on date range picker. The dates or ranges that have been selected are confirmed and the selected value is available in the value argument.
See also:
- showActionButtons, which allows to display action buttons at the bottom of the date range picker to handle the selection.
- onSelectionChanged, callback which notifies whenever the selection changed on date range picker.
- cancelText, which is text that display on the cancel button.
- confirmText, which is text that display on the confirm button
- onCancel, callback which notifies when the selection canceled through the cancel button of showActionButtons.
- Knowledge base: How to confirm or cancel the selection
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Date Range Picker'),
),
body: Container(
child: SfDateRangePicker(
showActionButtons: true,
onSubmit: (Object value) {
if (value is PickerDateRange) {
final DateTime rangeStartDate = value.startDate!;
final DateTime rangeEndDate = value.endDate!;
} else if (value is DateTime) {
final DateTime selectedDate = value;
} else if (value is List<DateTime>) {
final List<DateTime> selectedDates = value;
} else if (value is List<PickerDateRange>) {
final List<PickerDateRange> selectedRanges = value;
}
},
)));
}
Implementation
final Function(Object?)? onSubmit;