I want to change the language for the weekdays in intl:
to German. In my code, I do this:
final weekdayFormatter = DateFormat('E');
final date = mostRecentWeekday(_currentDate, 1).add(Duration(days: i)); "<-- Function to get current monday"
...
Text(weekdayFormatter.format(date)),
So I want Mo Di Mi Do which stands for Montag Dienstag Mittwoch […]
I tried this function: initializeDateFormatting();
but I don’t understand what parameters this function needs, especially the path parameter… all posts I were able to found are outdated
4
Answers
I solved it by do:
instead of:
also:
inside Matrerial app and
inside pub file
and using intl 17.
Hello you can try it
initializeDateFormatting('de_DE', null);
Add a line of code to the initState() method
First in your route
MaterialApp
Widget add this parameter :then use this script as language changer anywhere you need:
Make sure you use the right import of
initializeDateFormatting
. The easiest is to useimport 'package:intl/date_symbol_data_local.dart'
, for web and for custom file loading other variants exist indate_symbol_data_http_request.dart
anddate_symbol_data_file.dart
.