EDIT: Answer was very simple:
await initializeDateFormatting('pl_PL');
Above code was in conflict with:
GlobalMaterialLocalizations.delegate
Removing initializeDateFormatting helps.
I made a localization on my Flutter app. Unfortunately when I add GlobalMaterialLocalizations.delegate
to localizationsDelegates
there is an error. Removing GlobalMaterialLocalizations.delegate
provides app to work correctly but only English version. Another language (Polish) has a problem with AppBars (Again - after removing it (appbar) app works fine in that language too).
Part of my code:
localizationsDelegates: [
const ReadyLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('en', 'US'),
const Locale('pl', 'PL'),
],
Error:
Unsupported operation: Cannot set value in unmodifiable Map
Here is an error when I comment GlobalMaterialLocalizations.delegate (page has AppBar): https://pastebin.com/ENF5ZET7
As I said there is no error when localization is set to English.
If you just want to use the system's locale setting, there is no need to call initializeDateFormatting(). In your main.dart before calling runApp(), do this:
await findSystemLocale();
To call this method, you will need this import:
import 'package:intl/intl_standalone.dart';
As a reference, there is some documentation here -- https://api.flutter.dev/flutter/intl/Intl/systemLocale.html
await initializeDateFormatting('pl_PL');
Above code was in conflict with:
GlobalMaterialLocalizations.delegate
Removing initializeDateFormatting helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With