CalendarController _controller;
@override
void initState() {
_controller = CalendarController();
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: SafeArea(
child: Column(
children: [
Container(
height: 550,
child: SfCalendar(
view: CalendarView.day,
controller: _controller,
),
),
RaisedButton(
onPressed: () => _controller.view = CalendarView.week,
child: Text('Change the view'),
),
],
),
),
)));
} |
return SfCalendar(
controller: controller,
view: CalendarView.week,
dataSource: AppointmentProfDailyWeeklyBuilderLogic(appointments),
allowViewNavigation: true,
//initialDisplayDate: controller.displayDate,
//initialSelectedDate: controller.displayDate,
minDate: DateTime.now().roundDown(delta: Duration(minutes: 5)),
maxDate: DateTime.now().add(Duration(days: 365)),
firstDayOfWeek: DateTime.now().weekday,
showNavigationArrow: true,
onTap: (CalendarTapDetails details) {setState(() {onLongPress: (CalendarLongPressDetails details) {
controller.view = CalendarView.day ;
controller.displayDate = details.date ;
controller.selectedDate = details.date ;}
somemethod;
},
timeSlotViewSettings: TimeSlotViewSettings(
timeInterval: Duration 1 hour,
timeFormat: 'H:mm',
),
specialRegions: regions,
timeRegionBuilder:
(BuildContext context, TimeRegionDetails timeRegionDetails) {
return Container(.....
Hello,
i want to catch controller.view when allowed view is changed from view.month to view.timlinemonth ,but on tap method is not including changing allowed view .
Can anyone help me?
Scaffold(
body: SfCalendar(
headerHeight: 60,
showNavigationArrow: true,
viewNavigationMode: ViewNavigationMode.snap,
headerStyle: const CalendarHeaderStyle(
textAlign: TextAlign.center,
backgroundColor: Color(0xff015176),
textStyle: TextStyle(color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20)
),
view: CalendarView.month,
allowedViews: [
CalendarView.day,
CalendarView.week,
CalendarView.month,
CalendarView.timelineMonth
],
viewHeaderHeight: 60,
viewHeaderStyle: ViewHeaderStyle(backgroundColor: Colors.grey,
dayTextStyle: TextStyle(color: Colors.white, fontSize: 15)),
backgroundColor: _calendarColor,
controller: _controller,
initialDisplayDate: DateTime.now(),
todayHighlightColor: Colors.black,
monthViewSettings: MonthViewSettings(showAgenda: true),
timeSlotViewSettings:
TimeSlotViewSettings(timelineAppointmentHeight: 100),
dataSource: MeetingDataSource(_getDataSource()),
appointmentBuilder: appointmentBuilder,
onTap: calendarTapped,
)
void calendarTapped(CalendarTapDetails details) {
if(_controller.view==Month){
isScheduler=false;}else{
isScheduler=true;}
}
body: SfCalendar(
view: CalendarView.month, controller: _controller, dataSource: _getCalendarDataSource(), allowedViews: [CalendarView.month,CalendarView.timelineMonth,CalendarView.timelineWeek], onViewChanged: viewChanged, ) void viewChanged(ViewChangedDetails viewChangedDetails) { if(_controller.view==CalendarView.month) { // To do your requirement here. } else { // To do your requirement here. } } |
Wow, it took forever to find this answer. Can you please update your documentation for others that the Calendar Controller "view" property is not updated when using "allowed views"? Or fit that? That was a frustrating one.
Thanks!
Greg
Hi Syncfusion Team,
I'm facing an issue in the calendar widget by Syncfusion (Flutter) for the past 2 days. I have tried every workaround but nothing works for me.
Problem: i want to display an appointment indicator when an appointment gets selected for specific dates. I m able to show appointment in the bottom pop up widget in schdeule view. i want to show the indicator for the same appointment in parent month view widget.
My task (popup) widget get updated everytime and it works fine but its parent sf calendar month view doesnt get updated to show appointment indicator.
i have attached the screenshots zip file cuz i can't attach png file for some reason
nevermind got the issue solved by calling the provider in main.dart
Hi Kashif,
We are glad that your issue is resolved. Please let us know if you need any other assistance. We will be happy to assist you.
Regards,
Indumathi R