We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to programmatically navigate to the adjacent dates in the Flutter Calendar


In the Flutter Event Calendar, you can programmatically navigate to the adjacent dates by using the forward and backward method of CalendarController.

Inside the state, initialize the calendar controller.

final CalendarController? _controller = CalendarController();

Use the forward and backward properties of controller for programmatically change the adjacent dates.

Row(
  children: [
    Container(
    margin: const EdgeInsets.fromLTRB(30, 20, 0, 20),
      child: RaisedButton.icon(
        icon: Icon(Icons.arrow_back),
        label: Text('Backward'),
        onPressed: () {
          _controller.backward();
        },
      ),
    ),
    Container(
    margin: const EdgeInsets.fromLTRB(70, 20, 0, 20),
      child: RaisedButton.icon(
        label: Text('Forward'),
        icon: Icon(Icons.arrow_forward),
        onPressed: () {
          _controller.forward();
        },
      ),
    )
  ],
),

Assign _controller to the controller property of the calendar.

child: SfCalendar(
  controller: _controller,
),

View sample in GitHub

Forward and backward gif

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile