Hello,
I am trying out the Calendar and it looks great so far, however, I am running into a problem: I'm trying to display the calendar with a Day/Week/Month toggle (this works fine), but also another field with a Date picker so you can go to a different date quickly in the Calendar. This field needs to be up to date with the currentDate in the Calendar.
Using the onViewChanged method I can update the field with the date shown in the Calendar, but it doesn't work the other way around (_currentDate seems to be a private field). When I set the initialDisplayValue to that same value, strange stuff starts to happen when I swipe the Calendar (it sometimes skips a day).
I have a DateFilterModel which has a currentDate field, which is used for the DatePicker. Both the DatePicker widget and the Calendar use this DateFilterModel using a Provider. This is my build method, and the strange stuff starts when I set initalDisplayDate: _calendarModel.currentDate:
Widget build(BuildContext context) {
_calendarModel = Provider.of<DateFilterModel>(context);
//if (currentDate != _calendarModel.currentDate) currentDate = _calendarModel.currentDate;
return Stack(
children: <Widget>[
Container(
child: SfCalendar(
initialDisplayDate: currentDate,
view: _modes[mode],
todayHighlightColor: ColorConstants.secondary,
timeSlotViewSettings: TimeSlotViewSettings (timeFormat: StringConstants.of(context).timeFormat),
onViewChanged: (details) {
List<DateTime> dates = details.visibleDates;
_calendarModel.currentDate = dates.first;
},
),
),
_createHeaderRow(context),
],
);
}Any ideas what I am doing wrong here?
Thanks!