Articles in this section
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,
),

View the GitHub sample here

Flutter calendar view navigation

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied