I'm trying perform change appointment status and rebuild when operation has completed on API.
i tried to use notifyListeners, but not having success.
_controller.appointmentDataSource.notifyListeners(CalendarDataSourceAction.add, _controller.appointments);
// here appointment has been updated with a property updated on database.
// this method executed after operation in onPressed function button has completed
I'm using day view in calendar
My SfCalendar uses: dataSource: _controller.appointmentDataSource,
Atte, Adelmo.
Hi ADELMO,
Regarding Query: Reload list of appointments.
Based on the shared information, we suspect your requirement is “Reload the calendar appointments with new appointments in the Flutter Calendar”. By clearing the appointments in the data source and add the required appointments with notifyListeners. We have attached the simple code snippet for the same. Please find the code snippet from the below.
Code snippet:
|
TextButton( onPressed: () { _calendarDataSource.appointments?.clear(); List<Appointment> app = <Appointment>[]; app.add(Appointment( Subject: Meeting', StartTime: DateTime(2022, 12, 18, 10), EndTime: DateTime(2022, 12, 18, 11), Color: Colors.red, )); for (int i = 0; i < app.length; i++) { _calendarDataSource.appointments!.add(app[i]); } _calendarDataSource.notifyListeners( CalendarDataSourceAction.reset, _calendarDataSource.appointments!); }, child: Text("Click")), |
We hope that this helps you. If this is not your requirement, can you please share more details about your requirement clearly? It would be helpful for us to analyze and provide you a solution at the earliest.
Regards,
Indumathi R
Hi Indumathi R,
What I need is that when I change the appointment, it considers reloading the appointmentBuilder, as there are rules I use to change the appointments board view..
e.g.: Change color of title when appointment is closed
my appointmentBuilder
Hi ADELMO,
Regarding Query: Change color of title when appointment is closed
Based on the shared code snippet, we suspect your requirement is “Changing the color of the appointment based on the subject in appointmentbuilder of the Flutter Calendar”. We have prepared the simple sample with appointmentBuilder, and it was working fine. We have attached the code snippet for the same. Please find the code snippet for the same.
Code snippet:
|
Widget appointmentBuilder(BuildContext context, CalendarAppointmentDetails calendarAppointmentDetails) { final Appointment appointment = calendarAppointmentDetails.appointments.first; return Column( children: [ Container( width: calendarAppointmentDetails.bounds.width, height: calendarAppointmentDetails.bounds.height / 2, color: appointment.color, child: Center( child: Icon( Icons.group, color: Colors.black, ), )), Container( width: calendarAppointmentDetails.bounds.width, height: calendarAppointmentDetails.bounds.height / 2, color: appointment.color, child: Text( appointment.subject + DateFormat(' (hh:mm a').format(appointment.startTime) + '-' + DateFormat('hh:mm a)').format(appointment.endTime), textAlign: TextAlign.center, style: TextStyle( fontSize: 10, color: appointment.subject == "Planning" ? Colors.yellow : Colors.lightBlueAccent), ), ) ], ); } |
We hope that this helps you. Please let us know if you need further assistance.
Regards,
Indumathi R