How to get the day based on week number in flutter

So i have a json object which displays year, month and week of year:

{
  "year": 2021,
  "month": 8,
  "week": 31,
},
{
  "year": 2021,
  "month": 8,
  "week": 32,
}

My question is how can i iterate through the json object then convert the week of year into day of month where the day is the end of the week and then pass in the year, month and day of month into a DateTime object in flutter like this:

DateTime(2021,8,7)
DateTime(2021,8,14)

>Solution :

Multiply the week with a 7 to get the total number of days. Like

 int totaldays = week*7;
 final extraDuration = Duration(days: totaldays);
 final startDate = DateTime(2021);

  final newDateTime = startDate.add(extraDuration);

 print(newDateTime);

Leave a Reply