Articles in this section
Category / Section

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

3 mins read

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

 

Conclusion

I hope you enjoyed learning about how to programattically navigate the dates in adjacent dates in Flutter Calendar.

You can refer to our Flutter Calendar feature tour
page to know about its other groundbreaking feature representations documentation
and how to quickly get started for configuration specifications.  You can also explore our Flutter Calendar example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


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