CalendarDelegate<T extends DateTime> class
abstract
Controls the calendar system used in the date picker.
A CalendarDelegate defines how dates are interpreted, formatted, and navigated within the picker. Different calendar systems (e.g., Gregorian, Nepali, Hijri, Buddhist) can be supported by providing custom implementations.
This example demonstrates how a CalendarDelegate is used to implement a
custom calendar system in the date picker.
link
To create a local project with this code sample, run:
flutter create --sample=material.CalendarDelegate.1 mysample
See also:
- GregorianCalendarDelegate, the default implementation for the Gregorian calendar.
- CalendarDatePicker, which uses this delegate to manage calendar-specific behavior.
- Implementers
Constructors
- CalendarDelegate.new()
-
Creates a calendar delegate.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addDaysToDate(
T date, int days) → T - Returns a DateTime with the added number of days and time set to midnight.
-
addMonthsToMonthDate(
T monthDate, int monthsToAdd) → T -
Returns a DateTime that is
monthDate
with the added number of months and the day set to 1 and time set to midnight. -
dateHelpText(
MaterialLocalizations localizations) → String - The help text used on an empty InputDatePickerFormField to indicate to the user the date format being asked for.
-
dateOnly(
T date) → T - Returns a DateTime with the date of the original, but time set to midnight.
-
datesOnly(
DateTimeRange< T> range) → DateTimeRange<T> - Returns a DateTimeRange with the dates of the original, but with times set to midnight.
-
firstDayOffset(
int year, int month, MaterialLocalizations localizations) → int -
Computes the offset from the first day of the week that the first day of
the
month
falls on. -
formatCompactDate(
T date, MaterialLocalizations localizations) → String - Formats the date in a compact format.
-
formatFullDate(
T date, MaterialLocalizations localizations) → String - Formats day of week, month, day of month and year in a long-width format.
-
formatMediumDate(
T date, MaterialLocalizations localizations) → String - Formats the date using a medium-width format.
-
formatMonthYear(
T date, MaterialLocalizations localizations) → String -
Formats the month and the year of the given
date
. -
formatShortDate(
T date, MaterialLocalizations localizations) → String - Formats the date using a short-width format.
-
formatShortMonthDay(
T date, MaterialLocalizations localizations) → String -
Formats the month and day of the given
date
. -
formatYear(
int year, MaterialLocalizations localizations) → String - Full unabbreviated year format, e.g. 2017 rather than 17.
-
getDay(
int year, int month, int day) → T -
Returns a DateTime with the given
year
,month
, andday
. -
getDaysInMonth(
int year, int month) → int - Returns the number of days in a month, according to the calendar system.
-
getMonth(
int year, int month) → T -
Returns a DateTime with the given
year
andmonth
. -
isSameDay(
T? dateA, T? dateB) → bool - Returns true if the two DateTime objects have the same day, month, and year, or are both null.
-
isSameMonth(
T? dateA, T? dateB) → bool - Returns true if the two DateTime objects have the same month and year, or are both null.
-
monthDelta(
T startDate, T endDate) → int - Determines the number of months between two DateTime objects.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
now(
) → T - Returns a DateTime representing the current date and time.
-
parseCompactDate(
String? inputString, MaterialLocalizations localizations) → T? - Converts the given compact date formatted string into a DateTime.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited