date_picker
library
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.