We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to confirm or cancel the selection in the Flutter Date Range Picker

Platform: Flutter |
Control: SfDateRangePicker |
Published Date: April 28, 2021 |
Last Revised Date: May 6, 2021

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),
    ));
  },
),

View sample in GitHub

Flutter picker action buttons

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile