Official page
Import syncfusion_flutter_datepicker package
1 | dependencies: |
1 | import 'package:syncfusion_flutter_datepicker/datepicker.dart'; |
Add date range picker to the widget tree
Add the SfDateRangePicker widget as a child of any widget. Here, the SfDateRangePicker widget is added as a child of the scaffold widget.
1 |
|
Change different views
The SfDateRangePicker widget provides four different types of views to display. It can be assigned to the widget constructor by using the view property. Default view of the widget is month view. By default the current date will be displayed initially for all the date range picker views.
1 |
|
Change first day of week
The DateRangePicker widget will be rendered with Sunday as the first day of the week, but you can customize it to any day by using the firstDayOfWeek property.
1 |
|
Date selection
The DateRangePicker supports selecting single, multiple, and range of dates. It also supports programmatic selection.
The selected date or range details can be obtained using the onSelectionChanged callback of date range picker. The callback will return the DateRangePickerSelectionChangedArgs which contains the selected date or range details.
1 | void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { |
SelectionMode
Default selection mode pick only one date. but if you configure selection mode like the below code, you can get the range of date.
1 | SfDateRangePicker( |
args.value
I just arrange the properties name of start date and end date in DataRangePickerSelectionChangedArgs object. we should use these properties in onSelectionChanged callback function().
if) single date
- args.value
if) multiple date
- args.value.startDate
- args.value.endDate
1 | void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) { |