Failed assertion: line 150 pos 16: 'weeklyByDayPos != -1'

I want to add recurrenceRule for my schedule but this error happened:


======== Exception caught by widgets library =======================================================

The following assertion was thrown building LayoutBuilder:

Invalid weekly recurrence rule

'package:syncfusion_flutter_calendar/src/calendar/appointment_engine/recurrence_helper.dart':

Failed assertion: line 150 pos 16: 'weeklyByDayPos != -1'


The relevant error-causing widget was:

  SfCalendar file:///C:/Users/Iman/Projects/sistem-akademik/lib/schedule_screen.dart:99:26

When the exception was thrown, this was the stack:

#2 RecurrenceHelper.getRecurrenceDateTimeCollection (package:syncfusion_flutter_calendar/src/calendar/appointment_engine/recurrence_helper.dart:150:16)

#3 AppointmentHelper._getRecurrenceAppointments (package:syncfusion_flutter_calendar/src/calendar/appointment_engine/appointment_helper.dart:1424:41)

#4 AppointmentHelper.getVisibleAppointments (package:syncfusion_flutter_calendar/src/calendar/appointment_engine/appointment_helper.dart:1219:7)

#5 _SfCalendarState._getInitialScrollPosition (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:5387:27)

#6 _SfCalendarState.addAgenda (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:5228:46)


This is my snippet code:

MeetingDataSource getCalendarDataSource() {
List<Appointment> appointments = <Appointment>[];
appointments.add(Appointment(
from: DateTime(2021, 01, 25, 07, 00),
to: DateTime(2021, 01, 25, 07, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Pendidikan Anti Korupsi',
courseCode: 'KU4079',
lecturer: 'Dr. Wahid',
classroom: '02',
background: Colors.red));
appointments.add(Appointment(
from: DateTime(2021, 01, 25, 10, 00),
to: DateTime(2021, 01, 25, 10, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Pengembangan Aplikasi pada Platform Khusus',
courseCode: 'IF3210',
lecturer: 'Budi, S.T. M.T.',
classroom: '01',
background: Colors.blue));
appointments.add(Appointment(
from: DateTime(2021, 01, 25, 13, 00),
to: DateTime(2021, 01, 25, 13, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Grafika Komputer',
courseCode: 'IF3260',
lecturer: 'Tia, S.T. M.T.',
classroom: '02',
background: Colors.green));
appointments.add(Appointment(
from: DateTime(2021, 01, 25, 16, 00),
to: DateTime(2021, 01, 25, 16, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Sistem Paralel dan Terdistribusi',
courseCode: 'IF3230',
lecturer: 'Dr. Bambang, M.Sc.',
classroom: '03',
background: Colors.purple));
appointments.add(Appointment(from: DateTime(2021, 01, 26, 08, 00),
to: DateTime(2021, 01, 26, 08, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Agama dan Etika Islam',
courseCode: 'KU2061',
lecturer: 'Dr. Susilo, M.Ag.',
classroom: '01',
background: Colors.deepPurple));
appointments.add(Appointment(
from: DateTime(2021, 01, 26, 11, 00),
to: DateTime(2021, 01, 26, 11, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Pembelajaran Mesin',
courseCode: 'IF3270',
lecturer: 'Dr. Bambang',
classroom: '01',
background: Colors.lightBlueAccent));
appointments.add(Appointment(
from: DateTime(2021, 01, 26, 13, 30),
to: DateTime(2021, 01, 26, 13, 30).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Socio-informatika dan Profesionalisme',
courseCode: 'IF3280',
lecturer: 'Reno, Ph.D.',
classroom: '03',
background: Colors.deepOrange));
appointments.add(Appointment(
from: DateTime(2021, 01, 27, 07, 00),
to: DateTime(2021, 01, 27, 07, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Proyek Perangkat Lunak',
courseCode: 'IF3250',
lecturer: 'Dr. Sutrisno, S.T, M.T.',
classroom: '01',
background: Colors.blueGrey));
appointments.add(Appointment(
from: DateTime(2021, 01, 27, 15, 30),
to: DateTime(2021, 01, 27, 15, 30).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Grafika Komputer',
courseCode: 'IF3260',
lecturer: 'Tia, S.T. M.T.',
classroom: '02',
background: Colors.green));
appointments.add(Appointment(
from: DateTime(2021, 01, 28, 08, 30),
to: DateTime(2021, 01, 28, 08, 30).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Pengembangan Aplikasi pada Platform Khusus',
courseCode: 'IF3210',
lecturer: 'Budi, S.T. M.T.',
classroom: '01',
background: Colors.blue));
appointments.add(Appointment(
from: DateTime(2021, 01, 28, 13, 30),
to: DateTime(2021, 01, 28, 13, 30).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Proyek Perangkat Lunak',
courseCode: 'IF3250',
lecturer: 'Dr. Sutrisno, S.T, M.T.',
classroom: '01',
background: Colors.blueGrey));
appointments.add(Appointment(
from: DateTime(2021, 01, 28, 16, 00),
to: DateTime(2021, 01, 28, 16, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Sistem Paralel dan Terdistribusi',
courseCode: 'IF3230',
lecturer: 'Dr. Bambang, M.Sc.',
classroom: '03',
background: Colors.purple));
appointments.add(Appointment(
from: DateTime(2021, 01, 29, 07, 30),
to: DateTime(2021, 01, 29, 07, 30).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Proyek Perangkat Lunak',
courseCode: 'IF3250',
lecturer: 'Dr. Sutrisno, S.T, M.T.',
classroom: '01',
background: Colors.blueGrey));
appointments.add(Appointment(
from: DateTime(2021, 01, 29, 16, 00),
to: DateTime(2021, 01, 29, 16, 00).add(const Duration(hours: 2)),
recurrenceRule: 'FREQ=WEEKLY;COUNT=15',
eventName: 'Socio-informatika dan Profesionalisme',
courseCode: 'IF3280',
lecturer: 'Reno, Ph.D.',
classroom: '03',
background: Colors.deepOrange));
return MeetingDataSource(appointments);

3 Replies 1 reply marked as answer

IR Indumathi Ravichandran Syncfusion Team June 29, 2021 07:38 AM UTC

Hi Team, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked the mentioned issue “Exception occurred while using recurrence rule for appointments in Flutter Calendar” and we are unable to reproduce the mentioned exception from our end. For weekly recurrence appointment, you need to set the “BYDAY” property to recurring the events for that day. We have attached the code snippet for the same.  
 
Code snippet: 
MeetingDataSource _getCalendarDataSource() {
  List<Meeting> meetings = <Meeting>[];
  meetings.add(
Meeting(
    eventName:
'meeting',
    from:
DateTime(2021, 06, 29, 10),
    to:
DateTime(2021, 06, 29, 12),
    background: Colors.
green,
    isAllDay:
false,
    recurrenceRule:
'FREQ=WEEKLY;BYDAY=SU;COUNT=15',
  ));

 
return MeetingDataSource(meetings);
}
 
 
Also, we have prepared the simple sample for the same. Please find the sample from the link. 
 
 
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with following details, 
 
1.       Exception reproducing video. 
2.       Exception reproducing scenario. 
3.       Flutter Calendar package version. 
 
 It will be helpful for us to check on it and provide you solution at the earliest. 
 
Regards, 
Indumathi R 


Marked as answer

MD Mohamad Daffa replied to Indumathi Ravichandran June 29, 2021 09:40 AM UTC

Thank you very much for your answer. It's worked.



IR Indumathi Ravichandran Syncfusion Team June 29, 2021 11:02 AM UTC

Hi Team, 
Thank you for the update. Please get in touch with us if you would require any further assistance. 
Regards, 
Indumathi R 


Loader.
Up arrow icon