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