formatByLocale method
Locale short date: en_US 08/16/2023, en_GB/fr_FR 16/08/2023.
ddMMyyFormat forces the fixed dd MMM yy pattern instead of the locale
yMd skeleton. Returns null on failure (unloaded locale) so callers can
fall back to another format.
Audited: 2026-06-12 11:26 EDT
Implementation
String? formatByLocale({String? locale, bool ddMMyyFormat = false}) {
try {
return ddMMyyFormat
? DateFormat('dd MMM yy', locale).format(this)
: DateFormat.yMd(locale).format(this);
// Unloaded/malformed locale must degrade to null, never crash a UI.
// ignore: require_catch_logging -- display contract: never throw, callers fall back on null
} on Object {
return null;
}
}