Articles in this section
Category / Section

How to Confirm or Cancel the Selection in Flutter SfDateRangePicker?

2 mins read

In the Flutter SfDateRangePicker,  you can confirm or cancel the selected date or date ranges by enabling the showActionsButtons property. When enabled, this feature provides Cancel and Confirm buttons at the bottom of the picker. If the selection is canceled, the onCancel method is called but if it is confirmed, the onSubmit method is called.

You can customize the action button 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),
    ));
  },
),
View the Github Sample here.

Flutter picker action buttons


Conclusion

I hope you enjoyed learning about how to confirm or cancel the selection in Flutter SfDateRangePicker.

You can refer to our Flutter SfDateRangePicker feature tour page to learn about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied