formattedDate method

String formattedDate(
  1. BuildContext context, {
  2. String pattern = 'yyyy-MM-dd',
})

Formats the date using the locale from context.

Requires a Localizations ancestor above context (e.g. a MaterialApp); otherwise Localizations.localeOf throws.

Implementation

String formattedDate(BuildContext context, {String pattern = 'yyyy-MM-dd'}) {
  Locale locale = Localizations.localeOf(context);
  return DateFormat(pattern, locale.toString()).format(this);
}