如何解决错误:未为类“ ListLiteral”定义吸气剂“ elements2”。创建字符串翻译(.arb文件)时

时间:2019-05-25 02:10:36

标签: flutter dart-pub

我正在尝试生成字符串本地化文件,但是当我运行时 flutter pub run intl_translation:extract_to_arb --output-dir="lib/l10n" lib/localization/localizations.dart

它显示此错误:

Failed to precompile intl_translation:extract_to_arb: file:///D:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/intl_translation-0.17.4/lib/src/intl_message.dart:94:22: Error: The getter 'elements2' isn 't defined for the class 'ListLiteral'. - 'ListLiteral' is from 'package:analyzer/dart/ast/ast.dart' ('file:///D:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.34.3/lib/dart/a st/ast.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'elements2'. if (!identifiers.elements2.every((each) => each is SimpleIdentifier)) { ^^^^^^^^^

在此video之后,我已将“ l10n”添加到我的lib https://1drv.ms/u/s!AijASouhGkzqhIkjFGQbx7Wg7knsVg(这是显示我拥有的lib目录的屏幕截图)

这是我的localizations.dart文件。

1 个答案:

答案 0 :(得分:0)

我不确定它是否仍然有用,但这可能是'analyzer' package version的问题。 尝试升级您的依赖项和/或添加依赖项替代。它为我解决了这个问题。