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: [ CalendarView.day, CalendarView.week, CalendarView.workWeek, CalendarView.month, CalendarView.timelineDay, CalendarView.timelineWeek, CalendarView.timelineWorkWeek, CalendarView.timelineMonth ], 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(); } showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Container( child: new Text("Details shown by selection changed callback")), content: Container(child: new Text("You have selected " + '$_text')), actions: <Widget>[ new TextButton( onPressed: () { Navigator.of(context).pop(); }, child: new Text('close')) ], ); }); }
|
This page will automatically be redirected to the sign-in page in 10 seconds.