showDatePicker static method
Future<void>
showDatePicker(
- BuildContext context, {
- required void onDateSelected(),
- String? title,
- int? maxYear,
- String? type,
- CalendarTheme? theme,
- String? buttonText,
- 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,
);
},
);
}