Date class Null safety

A class that stores and manages day, month and year.

Implemented types
Annotations

Constructors

Date(int day, int month, int year)
Creates a Date object from day, month and year values. Performs validation.
Date.fromDateTime(DateTime dateTime)
Converts a DateTime to a Date.
Date.parse(String dateString)
Parses String to Date object. String must be formatted as ddmmyyyy. Performs validation. Throws FormatException when argument contains non-numbers.
Date.parseIso8601(String dateString)
Parses given String to a new Date object. Besides ISO 8601 works with every format of String that DateTime.parse would work with. Performs validation. Throws FormatException when the input can't be parsed.
Date.today()
Returns today's date.
Date.tomorrow()
Returns tomorrow's date.
Date.yesterday()
Returns yesterday's date.

Properties

day int
Returns day of the date represented by this object. Always in range 1; 31.
read-only
hashCode int
The hash code for this object.
read-onlyoverride
month int
Returns month of the date represented by this object. Always in range 1; 12.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
year int
Returns year of the date represented by this object.
read-only

Methods

addDays(int days) Date
Returns a new Date with given amount of days added to this. days can be negative, in this case subtraction will happen.
compareTo(Date other) int
Returns 0 if this is at the same date as other, 1 if this is after other and -1 if this is before other.
override
copyWith({int? day, int? month, int? year}) Date
Returns new Date modified with given input.
format(List<String> formats) String
Formats this with a given input. I.e. to get the String "11-03-2002", you want to call Date(11, 3, 2002).format([dd, '-', mm, '-', yyyy]). Available date modifiers are:
isAfter(Date other) bool
Checks if this is after other.
isBefore(Date other) bool
Checks if this is before other.
isTheSameDate(Date other) bool
Checks if this is the same date as other.
isToday() bool
Checks if this is today.
isTomorrow() bool
Checks if this is tomorrow.
isYesterday() bool
Checks if this is yesterday.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
subtractDays(int days) Date
Returns a new Date with given amount of days subtracted from this. days can be negative, in this case addition will happen.
toDateTime() DateTime
Returns DateTime object with the date of this and time values at 00:00.
toIso8601() String
Returns an ISO8601 String representing this. ISO8601 in this case means: yyyy-mm-ddT00:00:00.000000
toString() String
Returns this Date's object representations as String, with format ddmmyyyy. For other formatting options, use format method.
override

Operators

operator +(int days) Date
Returns a new Date with given amount of days added to this. days can be negative, in this case subtraction will happen.
operator -(int days) Date
Returns a new Date with given amount of days subtracted from this. days can be negative, in this case addition will happen.
operator <(Date other) bool
Checks if this is before other.
operator <=(Date other) bool
Checks if this is before or at the same day as other.
operator ==(dynamic other) bool
The equality operator.
override
operator >(Date other) bool
Checks if this is after other.
operator >=(Date other) bool
Checks if this is after or at the same day as other.