format method

String format(
  1. String formatStr, {
  2. Locale? locale,
})

Returns a string representation of this date with the format provided as a parameter.

Example: DateTime.now().format('yyyy-MM-dd') -> 2023-08-24.

Implementation

String format(String formatStr, {Locale? locale}) => DateFormat(
  formatStr,
  locale?.languageCode ?? FlutterSExtensions.locale?.languageCode,
).format(this);