Week class

A convenient class to work with only Week

Constructors

Week({required Date startOfWeek})
Constructs the week
const
Week.isoWeek(Date date)
Create the ISO week (week starting Monday) from date
factory
Week.lastWeek({bool iso = true})
Get last week
factory
Week.nextWeek({bool iso = true})
Get next week
factory
Week.now({bool iso = true})
When iso is true of absent, will return the current week starting on Monday When false, will return the current week starting on Sunday
factory
Week.startDateTime(DateTime datetime)
Create Week from DateTime
factory
Week.startWeek(Date date)
////////////////////////////////// FACTORIES Create Week from start Date
factory
Week.thisWeek({bool iso = true})
Same as Week.now
factory
Week.week(Date date)
Create a sunday Week (week starting on Sunday) from Date
factory

Properties

dates Map<DAY, Date>
Returns the dates of the week
no setter
endDay DAY
Returns endOfWeek as DAY;
no setter
endOfWeek Date
Get the date for the end of week - this is always a saturday or sunday
no setter
friday Date
Returns the friday Date of the week
no setter
hashCode int
The hash code for this object.
no setteroverride
isISOWeek bool
Returns true if week starts monday
no setter
isLastWeek bool
Return true if week is last week
no setter
isNextWeek bool
Return true if week is next week
no setter
isoWeekIndex int
Get the week index of ISO week
no setter
isThisWeek bool
Return true if week is this week
no setter
monday Date
Returns the monday Date of the week
no setter
next Week
/////////////////////////////// GETTERS Returns the next week relative to this week
no setter
previous Week
Returns the previous week relative to this week
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saturday Date
Returns the saturday Date of the week
no setter
startDay DAY
Returns the startOfWeek as DAY
no setter
startOfWeek Date
The start of the week, must be sunday or monday
final
sunday Date
Returns the sunday Date of the week
no setter
thursday Date
Returns the thursday Date of the week
no setter
tuesday Date
Returns the tuesday Date of the week
no setter
wednesday Date
Returns the wednesday Date of the week
no setter
weekIndex int
Get the week index of week
no setter

Methods

addWeeks(int amount) Week
Add a certain amount of weeks to this week
addYears(int amount) Week
Add a certain amount of years to this week
copyWith({Date? startOfWeek}) Week
////////////////////////////////// SETTERS Create a new copy with updated values
difference(Week other) int
////////////////////////////////// OPERATIONS Return the difference in weeks
isAfter(Week other) bool
////////////////////////////////// COMPARISON Return true if startOfWeek is after other, false otherwise.
isBefore(Week other) bool
Return true if startOfWeek is before other, false otherwise.
isSameOrAfter(Week other) bool
Return true if other isEqual or isAfter to this date
isSameOrBefore(Week other) bool
Return true if other isEqual or isBefore to this date
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setStartOfWeek(Date startOfWeek) Week
Set the year
subWeeks(int amount) Week
Subtracts an amount of months from this week
subYears(int amount) Week
Subtracts an amount of years from this Date
toKey() String
////////////////////////////////// KEY
toString() String
A string representation of this object.
override

Operators

operator <(Week other) bool
Less than operator
operator <=(Week other) bool
Less than or equals to operator
operator ==(Object other) bool
////////////////////////////////// OBJECT OVERRIDES
override
operator >(Week other) bool
Greater than operator
operator >=(Week other) bool
Greater or equals to operator
operator [](DAY day) Date
Convenient operator to get the date of a given week day

Static Methods

fromKey(String key) Week?
Parse from string in the format yyyy-ww - useful for unique week id
parse(String dateStr, {String? format, bool utc = false, bool iso = true}) Week
////////////////////////////////// FORMAT Constructs a new DateTime instance based on dateStr.
tryParse(String dateStr, {String? format, bool utc = false, bool iso = true}) Week?
Constructs a new DateTime instance based on dateStr.

Constants

firstISOWeekOfEpoch → const Week
Const value for the first week of epoch that can be used as a default value
firstISOWeekOfTime → const Week
Const value for the first week of year 1 that can be used as a default value
lastISOWeekOfTime → const Week
Const value to signify the end of time that can be used as a default value