showDatePicker static method

Future<void> showDatePicker(
  1. BuildContext context, {
  2. required void onDateSelected(
    1. int year,
    2. int month,
    3. int day
    ),
  3. String? title,
  4. int? maxYear,
  5. String? type,
  6. CalendarTheme? theme,
  7. String? buttonText,
  8. Widget? customButton,
})

Shows a date picker bottom sheet that can be called from anywhere.

Displays a modal bottom sheet with three scrollable pickers for day, month, and year selection.

Example usage:

CalendarBottomSheet.showDatePicker(
  context,
  onDateSelected: (year, month, day) {
    print('Selected date: $day/$month/$year');
  },
  theme: CalendarTheme.dark, // or CalendarTheme.light
);

Implementation

static Future<void> showDatePicker(
  BuildContext context, {
  required void Function(int year, int month, int day) onDateSelected,
  String? title,
  int? maxYear,
  String? type,
  CalendarTheme? theme,
  String? buttonText,
  Widget? customButton,
}) {
  return showModalBottomSheet(
    context: context,
    backgroundColor: Colors.transparent,
    builder: (BuildContext context) {
      return _DatePickerBottomSheet(
        onDateSelected: onDateSelected,
        title: title ?? "Select Date",
        maxYear: maxYear,
        type: type,
        theme: theme ?? CalendarTheme.light,
        buttonText: buttonText,
        customButton: customButton,
      );
    },
  );
}