showMonthYearPicker static method

Future<void> showMonthYearPicker(
  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 month/year picker bottom sheet (without day selection).

Displays a modal bottom sheet with two scrollable pickers for month and year selection only. The day parameter in the callback will always be 0.

Example usage:

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

Implementation

static Future<void> showMonthYearPicker(
  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 _MonthYearPickerBottomSheet(
        onDateSelected: onDateSelected,
        title: title ?? "Select Month/Year",
        maxYear: maxYear,
        type: type,
        theme: theme ?? CalendarTheme.light,
        buttonText: buttonText,
        customButton: customButton,
      );
    },
  );
}