displayDate error - setState() or markNeedsBuild() called during build.

When using instance.addPostFrameCallback() in order to programmatically change the date view using a calendarController.displayDate we're currently receiving the following exception:

setState() or markNeedsBuild() called during build.

This is interesting because under identical scenario, changing calendarController.selectedDate does work, and produces no error.

Any advice?


1 Reply

IR Indumathi Ravichandran Syncfusion Team February 8, 2021 06:40 AM UTC

Hi Cory, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked the mentioned error “setState() or markNeedsBuild() called during build in displayDate of the CalendarController in Flutter calendar” and it is working fine as expected from our end. We have prepared the simple sample for the same. Please find the sample from the following link. Also, we have attached the tested scenario for the same. 
 
Tested scenario: 
·       Changing the display date using onPressed callback of the RaisedButton. 
·       Changing the display date using onTap of the Flutter calendar. 
 
Sample 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 back with the following details, 
 
·       Replication procedure 
·       Issue reproducing video (if possible) 
·       Code snippet 
 
It will be helpful for us to check on it and provide you the solution at the earliest.   
 
Regards, 
Indumathi R 


Loader.
Up arrow icon