Articles in this section
Category / Section

How to do programmatic navigation using Flutter Date Range Picker (SfDateRangePicker)

1 min read

In the Flutter date range picker, you can programmatically navigate to the picker view using view property of the DateRangePickerController.

Inside the state, initialize the controller for the date picker.

final DateRangePickerController _controller = DateRangePickerController();
 
@override
void initState() {
  _controller.view=DateRangePickerView.year;
  super.initState();
}

Use the view property the date range picker controller inside the ElevatedButton pressed callback.

Container(
  margin: const EdgeInsets.fromLTRB(50, 130, 50, 0),
  child: ElevatedButton(child: Text('Change view'),onPressed: (){
    _controller.view=DateRangePickerView.month;
  },),
),

Assign controller to the controller property of the date picker.

child: SfDateRangePicker(
    controller: _controller
),

View sample in GitHub

Programmatic navigation using Flutter Date Picker

 

 

 

 

 

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