I want to set the locale of every showDatePicker
in the app, to the locale of the user's location, so that when they click the edit pencil in the DatePicker, they see the initial date in the format of their country.
I have found this to set the system locale:
Intl.systemLocale = await findSystemLocale();
Then when I use showDatePicker
I get that locale:
This does not format the date to the users country:
final systemLocale = Intl.systemLocale;
final splittedLocaleChars = systemLocale.split('_');
final locale = Locale(splittedLocaleChars[0], splittedLocaleChars[1]);
final selectedDate = await showDatePicker(
locale: locale,
And also this inside initState
should work:
findSystemLocale().then((value) {
Intl.systemLocale = value;
initializeDateFormatting(value, null);
});
"Unsupported operation: Cannot modify unmodifiable map"
What am I doing wrong?