Appointment disappears when navigating to another page

I have implemented a SfCalendar in my flutter app. I can add, edit and remove appointments but I noticed that when I go to another page and come back to the SfCalendar, whatever appointments that were added are no longer there. I feel like it has something to do with the done button for which the code is :

IconButton(
padding: const EdgeInsets.fromLTRB(5, 0, 5, 0),
icon: const Icon(
Icons.done,
color: Colors.white,
),
onPressed: () {
final List<Events> events = <Events>[];
if (_selectedAppointment != null) {
_events.appointments!.removeAt(
_events.appointments!.indexOf(_selectedAppointment));
_events.notifyListeners(CalendarDataSourceAction.remove,
<Events>[]..add(_selectedAppointment!));
}

events.add(Events(
from: _startDate,
to: _endDate,
background: _colorCollection[_selectedColorIndex],
description: _notes,
isAllDay: _isAllDay,
eventName: _subject == '' ? '(No title)' : _subject,
));

_events.appointments!.add(events[0]);

_events.notifyListeners(CalendarDataSourceAction.add, events);
_selectedAppointment = null;
Navigator.pop(context);
})


How do I save appointments?


Attachment: calendar_769ea025.zip

1 Reply 1 reply marked as answer

IR Indumathi Ravichandran Syncfusion Team November 3, 2021 11:57 AM UTC

Hi numa, 
 
Thank you for contacting Syncfusion support. 
 
Regarding Query: Appointment disappears when navigating to another page 
 
Based on the shared information, we have checked the mentioned issue “Appointment disappears when navigating to another page in the Flutter Calendar” and it was working fine as expected from our end. We have prepared the simple sample with drawer and the appointments are showing properly when navigating to the drawer page and back to calendar page. Please find the sample from the following link. 
 
Sample link: 
 
Also, we have KB document for appointment editor sample in the Flutter Calendar. Please find the KB documentation from the following link. 
 
KB link: 
 
If possible, can you please check the sample once and revert us back still if you are facing same issue? It would be helpful for us to analyze and provide you a solution at the earliest. 
 
Regards, 
 Indumathi R

Marked as answer
Loader.
Up arrow icon