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 get the selected dates using selection changed callback in the Flutter Calendar

In the Flutter Event Calendar, Using the onSelectionChanged callback, selected details can be shown in the Alert dialog window. The onSelectionChanged callback is triggered when controller selected date is changed.

In initState(), initialize the default values.

final CalendarController _controller = CalendarController();
String _text = '';

Use the onSelectionChanged callback like the following code snippet and show the details in the Alert dialog window.

child: SfCalendar(
  view: CalendarView.day,
  allowedViews: [
  controller: _controller,
  onSelectionChanged: selectionChanged,
void selectionChanged(CalendarSelectionDetails details) {
  if (_controller.view == CalendarView.month ||
      _controller.view == CalendarView.timelineMonth) {
    _text = DateFormat('dd, MMMM yyyy').format(details.date!).toString();
  } else {
    _text =
        DateFormat('dd, MMMM yyyy hh:mm a').format(details.date!).toString();
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Container(
              child: new Text("Details shown by selection changed callback")),
              Container(child: new Text("You have selected " + '$_text')),
          actions: <Widget>[
            new TextButton(
                onPressed: () {
                child: new Text('close'))

View sample in GitHub

Flutter calendar selectionchanged callback


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