Category / Section
How to confirm or cancel the selection in the Flutter Date Range Picker
2 mins read
In the Flutter Date Range Picker, Confirm or Cancel the selected date or date ranges by enabling the showActionsButtons. If it is cancelled, onCancel method is called but if it is confirmed, the onSubmit method is called.
Customize the action button’s text by using cancelText and confirmText property.
The code snippet for picker with range selection mode is attached below. In the same way showActionsButtons can be used for other views.
child: SfDateRangePicker( view: DateRangePickerView.month, selectionMode: DateRangePickerSelectionMode.range, showActionButtons: true, cancelText: 'CANCEL', confirmText: 'OK', onCancel: () { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text( 'Selection Cancelled', ), duration: Duration(milliseconds: 500), )); }, onSubmit: (Object value) { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text( 'Selection Confirmed', ), duration: Duration(milliseconds: 500), )); }, ),