Dart / Flutter default date format

I know this is already answered, but in case someone wants to use the actual device locale and not a hard-coded one:

DateFormat.yMMMd(Localizations.localeOf(context).languageCode).format(result);

Important, you need to pass a String and not a Locale object here.

If you want to have a custom date format, then you need to create your own switch/case based on all the locales you want to support.


You can pass a locale to DateFormat like

format = DateFormat.yMMMd("en_US");

See also

  • https://docs.flutter.io/flutter/intl/DateFormat-class.html
  • https://flutter.io/tutorials/internationalization