title: Dart / Flutter default date format
body: <p>I am trying to format <code>DateTime</code> result and display it to the user in user's current device locale.</p>
  
  <p>Currently I can either display entire <code>DateTime</code> such as following:</p>
  
  <blockquote>
    <p>2018-10-08 16:08:37.464112</p>
  </blockquote>
  
  <p>Or by specifying exact format like this:</p>
  
  <pre><code>DateFormat("dd.MM.yyyy").format(DateTime.now())
  </code></pre>
  
  <p>which results in following:</p>
  
  <blockquote>
    <p>08.10.2018</p>
  </blockquote>
  
  <p>My problem with this solution is, while this format might be acceptable in EU; in e.g. US (and many other countries) they are used to a different Date format, e.g.</p>
  
  <blockquote>
    <p>10/08/2018</p>
  </blockquote>
  
  <p><strong>My question is</strong>: how to return only Date (not time) to user in their current locale's format?  </p>
  
  <p><strong>Answer</strong>:<br>
  One needs to retrieve current locale and pass it to the format function. I am using custom localizations class, yet with out of the box solution it would look like this:</p>
  
  <pre><code>DateFormat.yMMMd(Localizations.localeOf(context)).format(result);
  </code></pre>