showCustomDateRangePicker function

void showCustomDateRangePicker(
  1. BuildContext context, {
  2. required bool dismissible,
  3. required DateTime minimumDate,
  4. required DateTime maximumDate,
  5. DateTime? startDate,
  6. DateTime? endDate,
  7. required dynamic onApplyClick(
    1. DateTime startDate,
    2. DateTime endDate
    ),
  8. required dynamic onCancelClick(),
  9. required Color backgroundColor,
  10. required Color primaryColor,
  11. String? fontFamily,
})

Displays a custom date range picker dialog box. context The context in which to show the dialog. dismissible A boolean value indicating whether the dialog can be dismissed by tapping outside of it. minimumDate A DateTime object representing the minimum allowable date that can be selected in the date range picker. maximumDate A DateTime object representing the maximum allowable date that can be selected in the date range picker. startDate A nullable DateTime object representing the initial start date of the date range selection. endDate A nullable DateTime object representing the initial end date of the date range selection. onApplyClick A function that takes two DateTime parameters representing the selected start and end dates, respectively, and is called when the user taps the "Apply" button. onCancelClick A function that is called when the user taps the "Cancel" button. backgroundColor The background color of the dialog. primaryColor The primary color of the dialog. fontFamily The font family to use for the text in the dialog.

Implementation

void showCustomDateRangePicker(
  BuildContext context, {
  required bool dismissible,
  required DateTime minimumDate,
  required DateTime maximumDate,
  DateTime? startDate,
  DateTime? endDate,
  required Function(DateTime startDate, DateTime endDate) onApplyClick,
  required Function() onCancelClick,
  required Color backgroundColor,
  required Color primaryColor,
  String? fontFamily,
}) {
  /// Request focus to take it away from any input field that might be in focus
  FocusScope.of(context).requestFocus(FocusNode());

  /// Show the CustomDateRangePicker dialog box
  showDialog<dynamic>(
    context: context,
    builder: (BuildContext context) => CustomDateRangePicker(
      barrierDismissible: true,
      backgroundColor: backgroundColor,
      primaryColor: primaryColor,
      minimumDate: minimumDate,
      maximumDate: maximumDate,
      initialStartDate: startDate,
      initialEndDate: endDate,
      onApplyClick: onApplyClick,
      onCancelClick: onCancelClick,
    ),
  );
}