【问题标题】:Flutter intl generated files, null safety problemFlutter intl 生成文件,null 安全问题
【发布时间】:2021-11-09 13:23:46
【问题描述】:

我的项目当前flutter版本是2.2.3,我的intl库版本是0.17.0。当我向任何语言文件添加新值时,我会在生成的文件中的 messages_all 和 l10n 文件中插入空安全语法。 代码 sn-ps:

MessageLookupByLibrary? _findExact(String localeName) {
  switch (localeName) {
    case 'ar':
      return messages_ar.messages;
    case 'de':
      return messages_de.messages;
    case 'en':
      return messages_en.messages;
    case 'fr':
      return messages_fr.messages;
    case 'ru':
      return messages_ru.messages;
    case 'tr':
      return messages_tr.messages;
    default:
      return null;
  }
}

MessageLookByLibrary?

当我编辑我的语言文件时:

flutter pub global run intl_utils:generate
INFO: No @@locale or _locale field found in intl_ar, assuming 'ar' based on the file name.
INFO: No @@locale or _locale field found in intl_de, assuming 'de' based on the file name.
INFO: No @@locale or _locale field found in intl_en, assuming 'en' based on the file name.
INFO: No @@locale or _locale field found in intl_fr, assuming 'fr' based on the file name.
INFO: No @@locale or _locale field found in intl_ru, assuming 'ru' based on the file name.
INFO: No @@locale or _locale field found in intl_tr, assuming 'tr' based on the file name.
Process finished with exit code 0

这样的错误,

如果我没有进行任何更改,我不会收到错误,但是当我进行最轻微的更改时,同样的错误会重复。

【问题讨论】:

  • 请提供您的错误信息和更多上下文
  • 我添加了更多信息

标签: flutter dart mobile localization intl


【解决方案1】:

我在安装最新版本 (2.5.1) 的 intl_utils 时遇到了同样的问题。为我解决的问题是停用和重新激活 intl_utils。

第一

flutter pub global deactivate intl_utils

然后重新安装最新版本

flutter pub global activate intl_utils 2.5.1

【讨论】:

    【解决方案2】:

    检查您是否安装了最新的 intl_utils。

    flutter pub global list
    

    如果您尚未安装最新版本,请运行此命令。 可以查看最新版本here

    flutter pub global activate intl_utils 2.4.1
    

    确保包名是 intl_utils

    这至少对我有帮助。

    干杯

    【讨论】:

      猜你喜欢
      • 2021-06-03
      • 2021-06-21
      • 2020-03-10
      • 2021-07-07
      • 2021-04-04
      • 2021-03-17
      • 2018-03-20
      相关资源
      最近更新 更多