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