flutter on demand loading for schedule view

Hi,

currently I perform incremental loading with the following code:

void _onViewChanged(ViewChangedDetails viewChangedDetails) {
SchedulerBinding.instance.addPostFrameCallback((duration) {
setState(() {
_future = /// code for getting future
});
}
But using CalendarView.schedule will not trigger the onViewChanged event. What I want to achieve is to incremental load additional items as the user navigates throug the view. Is this possible? I want to avoid that all the events are loaded.
Best regards,
Michael

5 Replies 1 reply marked as answer

IR Indumathi Ravichandran Syncfusion Team April 14, 2021 05:56 AM UTC

Hi Michael, 
 
Thank you for contacting Syncfusion support. 
 
Regarding Query: What I want to achieve is to incremental load additional items as the user navigates through the view. 
 
In the Flutter calendar onViewChanged callback was not triggered for schedule view of the calendar. Can you please use the onLoadMoreWidget for achieving your requirement? It creates a widget based on the load more details. Please find the API from the following link. 
 
 
 
Code snippet: 
 
final CalendarController _controller=CalendarController();SfCalendar(
  view: CalendarView.
week,
  dataSource: getCalendarDataSource(),
  loadMoreWidgetBuilder: loadMoreWidget
),
Widget loadMoreWidget(BuildContext context, LoadMoreCallback loadMoreAppointments) {
 
return FutureBuilder<String>(
    initialData:
'loading',
    future: loadMoreAppointments(),
    builder: (context, snapShot) {
     
return Container(
          height: _controller.view == CalendarView.
schedule
             
? 50
             
: double.infinity,
          width: double.
infinity,
          color: Colors.
white38,
          alignment: Alignment.
center,
          child:
CircularProgressIndicator(
              valueColor:
              
AlwaysStoppedAnimation(Colors.deepPurple)));
    },
  );
}
 
We hope that this helps you. Please let us know if you need further assistance. 
 
Regards, 
Indumathi R 


Marked as answer

MM Michael Mairegger April 14, 2021 06:39 AM UTC

Hi Indumathi,

unfortunately I cannot access the Web SB sample link since it is protected with Authentication. Does any public sample exist?

Michael


IR Indumathi Ravichandran Syncfusion Team April 14, 2021 07:31 AM UTC

Hi Michael, 
 
Sorry for the inconvenience caused. Can you please check the following link for Load More sample? 
 
  
Regards, 
Indumathi R 



MM Michael Mairegger April 14, 2021 03:25 PM UTC

Thanks for the sample. It works now. I missed the handleLoadMore method so the incremental loading did not happen.

Thanks for the excellent support.


IR Indumathi Ravichandran Syncfusion Team April 15, 2021 11:29 AM UTC

Hi Michael, 
 
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