format static method
Formats the date as a ISO-8601 date.
print(Dates.format(2023, 4, 1)); // '2023-04-01'
Implementation
@useResult static String format(int year, [int month = 1, int day = 1]) {
final sign = year < 0 ? '-' : '';
final yyyy = year.abs().toString().padLeft(4, '0');
final mm = month.toString().padLeft(2, '0');
final dd = day.toString().padLeft(2, '0');
return '$sign$yyyy-$mm-$dd';
}