Year class
Represents a calendar year (AD/CE).
This class wraps an integer value representing the year number. It includes helpers like leap year checks.
- Implemented types
Constructors
- Year.new(int value)
- Creates a Year instance.
- Year.fromDateTime(DateTime dateTime)
-
Creates a Year instance from a standard Dart DateTime object.
factory
- Year.now()
-
Creates a Year instance representing the current year based on the system clock.
factory
Properties
- daysInYear → int
-
Returns the number of days in this year (366 for leap years, 365 otherwise).
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isLeapYear → bool
-
Checks if this year is a leap year.
no setter
- next → Year
-
Returns the next year.
no setter
- previous → Year
-
Returns the previous year.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → int
-
The integer value of the year (e.g., 2024).
final
Methods
-
compareTo(
Year other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator <(
Year other) → bool - Checks if this year is strictly before another year.
-
operator <=(
Year other) → bool - Checks if this year is before or the same as another year.
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Year other) → bool - Checks if this year is strictly after another year.
-
operator >=(
Year other) → bool - Checks if this year is after or the same as another year.