Flutter intl生成文件,null安全问题

Erg*_*giz 3 mobile localization intl dart flutter

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

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;
  }
}
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

像这样的错误,

在此输入图像描述

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

在此输入图像描述

小智 7

我安装的最新版本(2.5.1)的 intl_utils 也遇到了同样的问题。对我来说解决这个问题的是停用并重新激活 intl_utils。

第一的

flutter pub global deactivate intl_utils
Run Code Online (Sandbox Code Playgroud)

然后重新安装最新版本

flutter pub global activate intl_utils 2.5.1
Run Code Online (Sandbox Code Playgroud)