controller property Null safety

HijriDatePickerController? controller

An object that used for programmatic date navigation, date and range selection and view switching in SfHijriDateRangePicker.

A HijriDatePickerController served for several purposes. It can be used to selected dates and ranges programmatically on SfHijriDateRangePicker by using thecontroller.selectedDate, controller.selectedDates, controller.selectedRange, controller.selectedRanges. It can be used to change the SfHijriDateRangePicker view by using the controller.view property. It can be used to navigate to specific date by using the controller.displayDate property.

Listening to property changes:

The HijriDatePickerController is a listenable. It notifies it's listeners whenever any of attached SfHijriDateRangePicker`s selected date, display date and view changed (i.e: selecting a different date, swiping to next/previous view and navigates to different view] in in SfHijriDateRangePicker.

Navigates to different view:

The SfHijriDateRangePicker visible view can be changed by using the Controller.view property, the property allow to change the view of SfHijriDateRangePicker programmatically on initial load and in run time.

Programmatic selection:

In SfHijriDateRangePicker selecting dates programmatically can be achieved by using the controller.selectedDate, controller.selectedDates, controller.selectedRange, controller.selectedRanges which allows to select the dates or ranges programmatically on SfHijriDateRangePicker on initial load and in run time.

Defaults to null.

See also:

This example demonstrates how to use the HijriDatePickerController for SfHijriDateRangePicker.

class MyApp extends StatefulWidget {
 MyAppState createState() => MyAppState();

class MyAppState extends State<MyApp> {
 HijriDatePickerController _pickerController =

 void initState() {
   _pickerController.selectedDates = <HijriDateTime>[ 2)), 4)), 7)), 11))
   _pickerController.displayDate =;

 void handlePropertyChange(String propertyName) {
   if (propertyName == 'selectedDates') {
     final List<HijriDateTime> selectedDates =
   } else if (propertyName == 'displayDate') {
     final HijriDateTime displayDate = _pickerController.displayDate!;

 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       body: SfHijriDateRangePicker(
         view: HijriDatePickerView.month,
         controller: _pickerController,
         selectionMode: DateRangePickerSelectionMode.multiple,


final HijriDatePickerController? controller;