isDate function

bool isDate(
  1. String str
)

Checks if the string represents a valid calendar date.

Accepts ISO-8601 strings such as 2023-12-01, 2023-12-01 12:00:00, and 2023-12-01T12:00:00Z. The YYYY-MM-DD prefix must be a real calendar date — month/day overflow such as 2023-13-01 or 2023-02-29 is rejected.

Example:

isDate('2023-12-01'); // true
isDate('2023-13-01'); // false
isDate('2023-02-29'); // false
isDate('invalid date'); // false

Implementation

bool isDate(String str) => _isDate(str);