WeekRange.weeksAgo constructor

WeekRange.weeksAgo(
  1. dynamic clock,
  2. dynamic ago, {
  3. RangeTitle titleFunction = _defaultTitle,
  4. int? startWeekday,
})

Constructs a WeekRange ending ago weeks ago from the date given by clock starting on the startWeekday.

The startWeekday is the 1-based first day of the week: e.g. DateTime.monday (which equals 1) for Monday, DateTime.tuesday for Tuesday, etc. It defaults to the first day of the week specified in the current locale.

Implementation

WeekRange.weeksAgo(clock, ago,
    {RangeTitle titleFunction = _defaultTitle, int? startWeekday})
    : this(
          _weekStart(
                  Date.today(clock),
                  startWeekday ??
                      (DateFormat().dateSymbols.FIRSTDAYOFWEEK + 1))
              .add(days: -7 * ago as int),
          ago,
          titleFunction,
          startWeekday);