A new Flutter package includes a day picker, week picker, and month picker.
Include short and useful examples for package users. For longer examples, please see the /example folder.
day_picker.dart
DateTime daySelected = DateTime.now();
String dayFormatted = DateFormat('yyyy/MM/dd').format(DateTime.now());
Text(
'Day:$dayFormatted',
style: TextStyle(
fontSize: 16.sp,
),
),
onPressed: () async {
CustomDayPickerDialog(
context: context,
primaryColor: Colors.black,
secondaryColor: Colors.white,
initialDate: daySelected,
onConfirm: (DateTime newSelectedDate) {
setState(() {
daySelected = newSelectedDate;
dayFormatted = DateFormat('yyyy/MM/dd')
.format(newSelectedDate);
});
},
).show();
},week_picker.dart
List<DateTime?> _dateRangePickerValue = [
DateTime.now(),
DateTime.now().add(const Duration(days: 6)),
];
String formatDate(List<DateTime?> dateRange) {
final startDate = DateFormat('yyyy/MM/dd').format(dateRange[0]!);
final endDate = DateFormat('yyyy/MM/dd').format(dateRange[1]!);
return '$startDate - $endDate';
}
Text(
'Week:${formatDate(_dateRangePickerValue)}',
style: TextStyle(
fontSize: 16.sp,
),
),
IconButton(
icon: Icon(
Icons.keyboard_arrow_down_outlined,
size: 24.sp,
),
onPressed: () async {
CustomWeekPickerDialog(
context: context,
primaryColor: Colors.black,
secondaryColor: Colors.white,
startDate: _dateRangePickerValue[0]!,
endDate: _dateRangePickerValue[1]!,
onConfirm: (DateTime startDate, DateTime endDate) {
setState(() {
_dateRangePickerValue = [
startDate,
endDate,
];
});
},
).show();
},
),month_picker.dart
DateTime monthSelected = DateTime.now();
String monthFormatted = DateFormat('yyyy/MM').format(DateTime.now());
Text(
'Month:$monthFormatted',
style: TextStyle(
fontSize: 16.sp,
),
),
onPressed: () async {
CustomMonthPickerDialog(
context: context,
primaryColor: Colors.black,
secondaryColor: Colors.white,
initialDate: monthSelected,
onConfirm: (DateTime newSelectedDate) {
setState(() {
monthSelected = newSelectedDate;
monthFormatted = DateFormat('yyyy/MM').format(newSelectedDate);
});
},
).show();
},-
daySelectedStores the currently selected date.
Type:
DateTimeDefault:
DateTime.now() -
dayFormattedStores the currently selected date formatted as 'yyyy/MM/dd'.
Type:
StringDefault:
DateFormat('yyyy/MM/dd').format(DateTime.now())
-
_dateRangePickerValueStores an array of two
DateTimeobjects representing the start and end of a date range.Type:
List<DateTime?>Default:
[DateTime.now(), DateTime.now().add(const Duration(days: 6))] -
formatDateFormats the date range from the
_dateRangePickerValuelist into a string showing the start and end dates.Type:
String Function(List<DateTime?> dateRange)Returns: A string formatted as 'yyyy/MM/dd - yyyy/MM/dd' representing the start and end dates.
-
monthSelectedStores the currently selected date.
Type:
DateTimeDefault:
DateTime.now() -
monthFormattedStores the currently selected date formatted as 'yyyy/MM'.
Type:
StringDefault:
DateFormat('yyyy/MM').format(DateTime.now())



