How to get date of specific day of the week in Flutter/dart?
Try this one:
var dayOfWeek = 1;
DateTime date = DateTime.now();
var lastMonday = date.subtract(Duration(days: date.weekday - dayOfWeek)).toIso8601String();
With dayOfWeek being 1 for Monday, 2 for Tuesday, and so on.
Try this one:
void main()
{
var monday=1;
var now = new DateTime.now();
while(now.weekday!=monday)
{
now=now.subtract(new Duration(days: 1));
}
print('Recent monday $now');
}