flutterdartintl

Flutter Intl (0.18!): Changing language for weekday


I want to change the language for the weekdays in intl: enter image description here

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


Solution

  • I solved it by do:

      final weekdayFormatter = DateFormat.E('de_DE');
    

    instead of:

    final weekdayFormatter = DateFormat('E');
    

    also:

          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
            DefaultWidgetsLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
          ],
    

    inside Matrerial app and

    dependencies:
      flutter:
        sdk: flutter
      flutter_localizations:
        sdk: flutter
    

    inside pub file

    and using intl 17.