Articles in this section
Category / Section

How to get the dropped resource details in the Flutter Calendar (SfCalendar)?

1 min read

In the Flutter Calendar, the dropped resource details can be achieved by using the onDragEnd callback of the calendar.

Step 1: Initialize the calendar and enable the allowDragAndDrop property.

child: SfCalendar(
  view: CalendarView.timelineWeek,
  allowedViews: _allowedViews,
  dataSource: _events,
  allowDragAndDrop: true,
  onDragEnd: dragEnd,
),

STEP 2: Using the onDragEnd callback, the changed target and source resource details can be achieved.

void dragEnd(AppointmentDragEndDetails appointmentDragEndDetails) {
  var targetResource = appointmentDragEndDetails.targetResource;
  var sourceResource = appointmentDragEndDetails.sourceResource;
  _showDialog(targetResource!, sourceResource!);
}
 
void _showDialog(
    CalendarResource targetResource, CalendarResource sourceResource) async {
  await showDialog(
    builder: (context) => AlertDialog(
      title: const Text("Dropped resource details"),
      contentPadding: const EdgeInsets.all(16.0),
      content: Text("You have dropped the appointment from " +
          sourceResource.displayName +
          " to " +
          targetResource.displayName),
      actions: <Widget>[
        TextButton(
            child: const Text('OK'),
            onPressed: () {
              Navigator.pop(context);
            })
      ],
    ),
    context: context,
  );
}

View Sample in GitHub

Flutter Calendar drag and drop resource details

 

I hope you enjoyed learning about how to get the dropped resource details in the Flutter Calendar (SfCalendar)

You can refer to our Flutter Calendar feature tour page to know about its other groundbreaking feature representations. You can also explore our Flutter Calendar 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