We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

onViewChanged causing inifite loop even with addPostFrameCallback()

I`m using flutter bloc to handle states, but when I try this to only search for data that is in the calendar range, it turns in a infinite loop

onViewChanged: (ViewChangedDetails details) {

                                List<DateTime> dates = details.visibleDates;

                                SchedulerBinding.instance!.addPostFrameCallback((_) async {

                                  setState(() {

                                    eventTrigger(context, dates.first, dates.last);

                                  });

                                });

                              },


eventTrigger function:

void eventTrigger(BuildContext context, DateTime initialDate, DateTime endDate) {

  context.read<CompromissoAgendaListBloc>().add(CompromissoPeriodoDeBusca(initialDate, endDate));

  context.read<ContratoAgendaListBloc>().add(ContratoPeriodoDeBusca(initialDate, endDate));


  context.read<CompromissoAgendaListBloc>().add(CompromissoAgendaListLoaded());

  context.read<ContratoAgendaListBloc>().add(ContratoAgendaListLoaded());


}


1 Reply

MS Muniappan Subramanian Syncfusion Team April 4, 2023 01:21 PM UTC

According to the instructions provided, we followed the steps to check the reported issue but were unable to replicate it on our end. We conducted tests by loading the Flutter Calendar in the Bloc state management and it’s working fine. We have prepared a simple sample based on the given code snippets, which are attached for your reference.


Please note that the version of SfCalendar used for this test is 21.1.38.


Please check our sample and let us know if you still facing the same issue. if not, please modify our sample and revert us back with the following details which would be helpful for us to check on it and provide you the solution as soon as possible,


  • A video demonstrating the issue you are facing.

  • A reproducible sample that demonstrates the issue.

  • Calendar version details


Providing these details would be helpful for us to investigate the issue and provide you with a solution as soon as possible.


Attachment: Sample_fef56b8f.zip

Loader.
Live Chat Icon For mobile
Up arrow icon