Flutter 如何解决flatter\u-cupertino\u本地化包编译错误

Flutter 如何解决flatter\u-cupertino\u本地化包编译错误,flutter,Flutter,我的项目使用Flatter_cupertino_本地化包,用于编译和运行良好。到今天为止,我得到以下编译错误 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 fo

我的项目使用Flatter_cupertino_本地化包,用于编译和运行良好。到今天为止,我得到以下编译错误

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)

flatter--version
的输出为:

颤振1.5.8•通道未知•来源未知 框架•版本0ba67226ee(6个月前)•2019-04-24 17:18:28-0700 发动机•版本c63d1cf9c9
工具•Dart 2.3.0(构建2.3.0-dev.0.1 1f1592edce)

对于最新的
颤振定位,您不再需要
颤振定位。请参阅最新版本,其中包含cupertino本地化方法。is当前(截至2020年1月7日)已过时,需要更改为不告诉人们我们需要使用
flatter\u-cupertino\u本地化
包。

可能会显示错误,因为您在
MaterialApp中配置了以下区域设置:

  MaterialApp(
  ...
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
    ],
    supportedLocales: [const Locale('pt', 'BR')],
  );
  MaterialApp(
  ...
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: [const Locale('pt', 'BR')],
  );
但是您忘记了在您的
localizationsDelegates
中添加
GlobalCupertinoLocalizations.delegate
。然后,要解决此问题,只需添加如下内容:

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

但如果您删除所有这些配置,您的应用程序将加载默认配置,并将完美工作。但是默认语言是英语。

这可能是软件包的错误,一些软件包没有为更新的flift或Xcode发布,因此您会得到错误。进一步研究,如果是这样的话,你必须寻找其他类似的软件包,它与颤振的更新版本兼容。