isBeforeOrSameMomentAs function Null safety

Matcher isBeforeOrSameMomentAs(
  1. DateTime date

Validates that a DateTime is before or the same moment as date.

This matcher has additional behavior when used in expectResponse, hasResponse, hasHeaders, hasBody: if the actual value is a String, it will attempted to be parsed into a DateTime first. If parsing fails, this matcher will fail.

    expectResponse(response, 200, headers: {"x-timestamp": isBeforeOrSameMomentAs(DateTime())});


Matcher isBeforeOrSameMomentAs(DateTime date) {
  return predicate((DateTime d) => d.isBefore(date) || d == date,
      "before or same moment as ${date.toIso8601String()}");