date_picker library

Classes

CustomDateField
Field for a single date. type chooses spin, calendar, dropdown, or input.
CustomDatePickerTheme
Provides CustomDatePickerThemeData to the picker currently on screen.
CustomDatePickerThemeData
Colors, sizes, and text styles shared by every picker view.
CustomDateRangeField
Field for a start and end date, shown as DD/MM/YYYY – DD/MM/YYYY.
CustomTimeField
Field for one time. type chooses spin, dropdown, or input.
DdMmYyyyInputFormatter
Inserts slashes so 09102026 becomes 09/10/2026.
HhMmInputFormatter
Inserts a colon so 1430 becomes 14:30.

Enums

DatePickerType
Which picker view a public widget opens.
TimePickerType
Which time view a field or sheet opens.

Constants

monthAbbreviations → const List<String>
monthNames → const List<String>

Functions

clampDate(DateTime date, DateTime firstDate, DateTime lastDate) → DateTime
clampDateParts({required int year, required int month, required int day, required DateTime firstDate, required DateTime lastDate}) → DateTime
Builds a valid date inside firstDate and lastDate.
clockHour(int hour24) → int
Clock helpers for an hour and minute picker.
dateOnly(DateTime date) → DateTime
daysInMonth(int year, int month) → int
formatDdMmYyyy(DateTime date, {String separator = '/'}) → String
Formats a date as 09/10/2026.
formatHhMm(TimeOfDay time, {bool use24Hour = true}) → String
14:30 in 24-hour mode, or 02:30 PM in 12-hour mode.
hour24FromClock(int clock, DayPeriod period) → int
Converts a 12-hour clock hour plus AM/PM into an hour from 0 to 23.
isLeapYear(int year) → bool
normalizeTime(TimeOfDay time, {int minuteInterval = 1}) → TimeOfDay
Snaps time to the nearest minuteInterval.
showCustomDatePicker({required BuildContext context, DatePickerType type = DatePickerType.spin, DateTime? initialDate, DateTime? firstDate, DateTime? lastDate, CustomDatePickerThemeData theme = CustomDatePickerThemeData.minimal}) → Future<DateTime?>
Opens a spin, calendar, or dropdown picker. The result is one calendar day.
showCustomDateRangePicker({required BuildContext context, DateTime? initialStart, DateTime? initialEnd, DateTime? firstDate, DateTime? lastDate, CustomDatePickerThemeData theme = CustomDatePickerThemeData.minimal}) → Future<DateTimeRange<DateTime>?>
Opens the range calendar. Confirm returns a start and an end.
showCustomTimePicker({required BuildContext context, TimePickerType type = TimePickerType.spin, TimeOfDay? initialTime, bool use24Hour = true, int minuteInterval = 1, CustomDatePickerThemeData theme = CustomDatePickerThemeData.minimal}) → Future<TimeOfDay?>
Opens a spin or dropdown time picker. The result is one TimeOfDay.
tryParseDdMmYyyy(String text) → DateTime?
Reads 09/10/2026. Returns null when the text is not a real calendar day.
tryParseHhMm(String text) → TimeOfDay?
Parses HH:mm, or hh:mm AM / hh:mm PM. Returns null when it is not a real time.