您可以使用https://api.dart.dev/stable/2.5.1/dart-core/DateTime/weekday.html从日期时间中获取工作日,然后从日期中加/减以下数字:
void main() {
final date = DateTime.parse('2019-10-08 15:43:03.887');
print('Date: $date');
print('Start of week: ${getDate(date.subtract(Duration(days: date.weekday - 1)))}');
print('End of week: ${getDate(date.add(Duration(days: DateTime.daysPerWeek - date.weekday)))}');
}
DateTime getDate(DateTime d) => DateTime(d.year, d.month, d.day);
UPDATE个
请阅读并对爱尔兰国税局的答案投上赞成票.他对这方面的了解比我多得多.:)