我的项目使用flutter_cupertino_localizations包,可以很好地编译和运行。到今天为止,我得到了低于编译错误的结果。
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);上一次我在这个项目上工作时(几周前),这个程序编译得很好。我能想到的唯一改变的是我正在使用的Xcode版本(以前是版本10,现在是版本11)。
flutter --version的输出为:
Flutter 1.5.8·通道未知·未知源代码框架·修订版0ba67226ee (6个月前)·2019-04-24 17:18:28 -0700 Engine·修订版c63d1cf9c9工具·Dart 2.3.0 (build 2.3.0-dev.0.1 1f1592edce)
发布于 2020-01-07 17:22:29
对于最新的flutter_localizations,您不再需要flutter_cupertino_localizations。查看最新的flutter_localizations documentation,它包含了库比蒂诺的本地化方法。flutter website for internationalization目前(截至2020年1月7日)已过期,需要更改为不告诉人们我们需要使用flutter_cupertino_localizations包。
发布于 2021-04-22 21:55:38
之所以显示该错误,可能是因为您在MaterialApp中配置了如下区域设置:
MaterialApp(
...
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [const Locale('pt', 'BR')],
);但是你忘了在你的localizationsDelegates中添加GlobalCupertinoLocalizations.delegate。然后,要解决这个问题,只需像这样添加它:
MaterialApp(
...
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [const Locale('pt', 'BR')],
);但如果你删除了所有这些配置,你的应用程序将加载默认配置,并将完美工作。但是默认的语言是英语。
https://stackoverflow.com/questions/58338413
复制相似问题