HijriDatePickerController class
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 the controller.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 rum 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:
- SfHijriDateRangePicker.initialDisplayDate, which used to navigate the date range picker to the specific date initially.
- SfHijriDateRangePicker.initialSelectedDate, which allows to select date programmatically initially on date range picker.
- SfHijriDateRangePicker.initialSelectedDates, which allows to list of select date programmatically initially on date range picker.
- SfHijriDateRangePicker.initialSelectedRange, which allows to select a range of dates programmatically initially on date range picker.
- SfHijriDateRangePicker.initialSelectedRanges, which allows to select a ranges of dates programmatically initially on date range picker.
- selectedDate,which allows to select date programmatically dynamically on date range picker.
- selectedDates, which allows to select dates programmatically dynamically on date range picker.
- selectedRange, which allows to select range of dates programmatically dynamically on date range picker.
- selectedRanges, which allows to select ranges of dates programmatically dynamically on date range picker.
- SfHijriDateRangePicker.selectionMode, which allows to customize the selection mode with available mode options.
- SfHijriDateRangePicker.onViewChanged, the callback which notifies when the current view visible date changed on the date range picker.
- SfHijriDateRangePicker.onSelectionChanged, the callback which notifies when the selected cell changed on the the date range picker.
- SfHijriDateRangePicker.showActionButtons, which allows to cancel of confirm the selection in the date range picker.
- SfHijriDateRangePicker.onSubmit, the callback which notifies when the selected value confirmed through confirm button on date range picker.
- SfHijriDateRangePicker.onCancel, the callback which notifies when the selected value canceled and reverted to previous confirmed value through cancel button on date range picker.
- Knowledge base: How to get the selected date
- Knowledge base: How to select a week
- Knowledge base: How to select all days when clicking on the day header
- Knowledge base: How to confirm or cancel the selection
- Knowledge base: How to select previous or next dates bases on selected date
- Knowledge base: How to get the start and end date of the selected range
- Knowledge base: How to programmatically select the date
- Knowledge base: How to do programmatic navigation
- Knowledge base: How to programmatically navigate to adjacent dates
- Knowledge base: How to programmatically navigate
This example demonstrates how to use the HijriDatePickerController for SfHijriDateRangePicker.
class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
HijriDatePickerController _pickerController = HijriDatePickerController();
@override
void initState() {
_pickerController.selectedDates = <HijriDateTime>[
HijriDateTime.now().add(Duration(days: 2)),
HijriDateTime.now().add(Duration(days: 4)),
HijriDateTime.now().add(Duration(days: 7)),
HijriDateTime.now().add(Duration(days: 11))
];
_pickerController.displayDate = HijriDateTime.now();
_pickerController.addPropertyChangedListener(handlePropertyChange);
super.initState();
}
void handlePropertyChange(String propertyName) {
if (propertyName == 'selectedDates') {
final List<HijriDateTime> selectedDates =
_pickerController.selectedDates!;
} else if (propertyName == 'displayDate') {
final HijriDateTime displayDate = _pickerController.displayDate!;
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SfHijriDateRangePicker(
view: HijriDatePickerView.month,
controller: _pickerController,
selectionMode: DateRangePickerSelectionMode.multiple,
),
),
);
}
}
- Inheritance
-
- Object
- DateRangePickerValueChangeNotifier
- HijriDatePickerController
Constructors
Properties
- backward ↔ VoidCallback?
-
Moves to the previous view programmatically with animation by checking
that the previous view dates falls between the minimum and maximum date
range.
getter/setter pair
- displayDate ↔ HijriDateTime?
-
The first date of the current visible view month, when the
HijriDatePickerMonthViewSettings.numberOfWeeksInView
set with default value 6.getter/setter pair - forward ↔ VoidCallback?
-
Moves to the next view programmatically with animation by checking that
the next view dates falls between the minimum and maximum date range.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedDate ↔ HijriDateTime?
-
The selected date in the SfHijriDateRangePicker.
getter/setter pair
-
selectedDates
↔ List<
HijriDateTime> ? -
The list of dates selected in the SfHijriDateRangePicker.
getter/setter pair
- selectedRange ↔ HijriDateRange?
-
selected date range in the SfHijriDateRangePicker.
getter/setter pair
-
selectedRanges
↔ List<
HijriDateRange> ? -
List of selected ranges in the SfHijriDateRangePicker.
getter/setter pair
- view ↔ HijriDatePickerView?
-
The current visible HijriDatePickerView of
SfHijriDateRangePicker.
getter/setter pair
Methods
-
addPropertyChangedListener(
DateRangePickerValueChangedCallback listener) → void -
Calls the listener every time the controller's property changed.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener
andremoveListener
will throw after the object is disposed).inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyPropertyChangedListeners(
String value) → void -
Call all the registered listeners.
inherited
-
removePropertyChangedListener(
DateRangePickerValueChangedCallback listener) → void -
remove the listener used for notify the data source changes.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited