Category / Section
How to do programmatic navigation using Flutter Calendar
2 mins read
In the Flutter Event Calendar, you can programmatically navigate between calendar views using the view property of the CalendarController.
Inside initState() method, initialize the controller for the calendar.
final CalendarController _controller = CalendarController();
Use the view property the calendar controller inside the RaisedButton onPressed callback.
Container( margin: const EdgeInsets.fromLTRB(50, 30, 50, 0), child: RaisedButton( child: Text('Change view'), onPressed: () { _controller.view = CalendarView.timelineWeek; }, ), ),
Assign the controller to the controller property of the calendar.
child: SfCalendar( view: CalendarView.workWeek, controller: _controller, ),