Category / Section
How to handle the long press action on date selection in the Flutter Calendar
In the Flutter Event Calendar, you can handle the long press action on the date selection using onLongPress callback.
void longPressed(CalendarLongPressDetails calendarLongPressDetails) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title:Container(child: new Text(" Long pressed")),
content:Container(child: new Text("Date cell " +DateFormat('dd MMM')
.format(calendarLongPressDetails.date)
.toString()+ " has been long pressed")),
actions: <Widget>[
new FlatButton(onPressed: (){
Navigator.of(context).pop();
}, child: new Text('close'))
],
);
});
}
child: SfCalendar(
view: CalendarView.month,
onLongPress: longPressed,
allowedViews: <CalendarView>[
CalendarView.day,
CalendarView.week,
CalendarView.workWeek,
CalendarView.month,
CalendarView.timelineDay,
CalendarView.timelineWeek,
CalendarView.timelineWorkWeek,
CalendarView.timelineMonth,
CalendarView.schedule
],
),
|
|
|
Day Week Work week
|
|
|
Month Timeline day Timeline week
|
|
|
Timeline work week Timeline month Schedule








