Sander48k
Sander48k

Reputation: 73

How to resolve flutter_cupertino_localizations package compile error

My project uses the flutter_cupertino_localizations package and used to compile and run fine. As of today I am getting below compile error.

Compiler message:
file:///Users/.../Applications/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_cupertino_localizations-1.0.1/lib/src/cupertino_localizations.dart:127:38: Error: Getter not found: 'kSupportedLanguages'.
  bool isSupported(Locale locale) => kSupportedLanguages.contains(locale.languageCode);

This used to compile fine the last time I worked on this project (a few weeks back). The only thing I can think off that has changed is the Xcode version I am using (was version 10, is now version 11).

The output of flutter --version is:

Flutter 1.5.8 • channel unknown • unknown source Framework • revision 0ba67226ee (6 months ago) • 2019-04-24 17:18:28 -0700 Engine • revision c63d1cf9c9 Tools • Dart 2.3.0 (build 2.3.0-dev.0.1 1f1592edce)

Upvotes: 0

Views: 1471

Answers (2)

Clairton Luz
Clairton Luz

Reputation: 2344

That erros probably is show because you config locales in your MaterialApp like this:

  MaterialApp(
  ...
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
    ],
    supportedLocales: [const Locale('pt', 'BR')],
  );

but you forgot of add GlobalCupertinoLocalizations.delegate in you localizationsDelegates. Then to fix this problem just add it like this:

  MaterialApp(
  ...
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: [const Locale('pt', 'BR')],
  );

but if you remove all this configurations, you app will load configuration default and will works perfectly. But the language default is English.

Upvotes: 2

Nelson Yeung
Nelson Yeung

Reputation: 3382

You do not need flutter_cupertino_localizations anymore for the latest flutter_localizations. See the latest flutter_localizations documentation, it contains cupertino localizations methods. The flutter website for internationalization is currently (as of 7th Jan 2020) is out of date and needs to be changed to not tell people we need to use flutter_cupertino_localizations package.

Upvotes: 1

Related Questions