1

I want to change the default date picker date format. The default format of date picker is "MM/DD/YYYY". But i want "DD/MM/YYYY".

2 Answers2

2

you can do this by updating your apps (or just the widgets) locale:

await showDatePicker(locale: const Locale('de')); 

'de' for germany, but pick whatever countryCode you require.

Andrej
  • 2,743
  • 2
  • 11
  • 28
cas
  • 757
  • 4
  • 19
  • Don't you need to specify MaterializationDelegates in your root MaterialApp widget? Or is this optional? MaterializationDelegates are; localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], – berkaykurkcu May 19 '23 at 20:01
1

so in order to display the date format. for e.g:

Text( '${DateFormat.yMd().format(_selectedDate)}'),

check out DateFormat docs at https://api.flutter.dev/flutter/intl/DateFormat-class.html for your format .

Rex
  • 250
  • 1
  • 3
  • 18