简体   繁体   English

Flutter - 命名参数未根据 pub.dartlang.org 定义,但该包有效

[英]Flutter - named parameters aren't defined according to pub.dartlang.org, but the package works

I just created my first contribution to flutter.我刚刚创建了我对 flutter 的第一个贡献。 I can use my package just fine, but I get a very low score because of some errors found by dart analysis.我可以很好地使用我的包,但由于 dart 分析发现的一些错误,我得到了很低的分数。 I am using the GestureDetector class and implemented callbacks for onLongPressDragStart , onLongPressDragUpdate and onLongPressDragUp .我正在使用 GestureDetector 类并为onLongPressDragStartonLongPressDragUpdateonLongPressDragUp实现回调。 According to the analysis after publishing my package these are wrong:根据发布我的包后的分析,这些是错误的:

Fix lib/planner_class.dart. (-57.81 points)
Analysis of lib/planner_class.dart failed with 3 errors:
line 163 col 21: The named parameter 'onLongPressDragStart' isn't defined.
line 168 col 21: The named parameter 'onLongPressDragUpdate' isn't defined.
line 173 col 21: The named parameter 'onLongPressDragUp' isn't defined.

But these are defined in the GestureDetector class ( https://docs.flutter.io/flutter/widgets/GestureDetector-class.html ).但是这些是在 GestureDetector 类 ( https://docs.flutter.io/flutter/widgets/GestureDetector-class.html ) 中定义的。 My offending code can be found here on github ( https://github.com/ourtrip/planner/blob/7c4c6bb8533ab9ecb66c61ba757a88ba2aaf8092/lib/planner_class.dart#L163 ).我的违规代码可以在 github 上找到( https://github.com/ourtrip/planner/blob/7c4c6bb8533ab9ecb66c61ba757a88ba2aaf8092/lib/planner_class.dart#L163 )。 Oddly enough, the other callbacks ( onScaleStart and onScaleUpdate ) don't throw an error.奇怪的是,其他回调( onScaleStartonScaleUpdate )不会抛出错误。

The dart package with the errors can be found here: https://pub.dartlang.org/packages/planner#-analysis-tab- .可以在此处找到包含错误的 dart 包: https ://pub.dartlang.org/packages/planner#-analysis-tab-。

So what could be causing this?那么是什么原因造成的呢? And how do i fix it?我该如何解决?

I had the same problem.我有同样的问题。

The problem here is, that you've maybe used the latest features of Flutter.这里的问题是,您可能已经使用了 Flutter 的最新功能。 You've to look into the Widgets/Parameters you're using for your implementation.您必须查看用于实施的小部件/参数。 And set the minimum Flutter SDK version in your pubspec.yaml to let pub.dev know at which version of Flutter SDK your package will be supported (eg newest features).并在你的 pubspec.yaml 中设置最低的 Flutter SDK 版本,让 pub.dev 知道你的包将支持哪个版本的 Flutter SDK(例如最新功能)。

For example edit your pubspec as follow:例如,按如下方式编辑您的 pubspec:

environment:
  sdk: ">=2.2.2 <3.0.0"
  flutter: ">=1.12.0 <2.0.0"

Best regards最好的祝福

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 amplify_flutter 任何不存在的(在 https://pub.dartlang.org 上找不到 package amplify_flutter), - amplify_flutter any which doesn't exist (could not find package amplify_flutter at https://pub.dartlang.org), Flutter:看起来 pub.dartlang.org 遇到了一些问题 - Flutter: It looks like pub.dartlang.org is having some trouble 对 https://pub.dartlang.org package 存储库中资源的权限不足 - Insufficient permissions to the resource in https://pub.dartlang.org package repository Flutter - 如何在 pub.dartlang.org 之外使用包 - Flutter - how to use packages outside pub.dartlang.org Flutter 创建导致错误尝试在 https://pub.dartlang.org 上查找包 cupertino_icons 时出现 TLS 错误 - Flutter create results in error Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org Flutter 错误在“H:\Flutter\.pub-cache\hosted\pub.dartlang.org\vm_service-7.3.0”中找不到名为“pubspec.yaml”的文件 - Flutter error Could not find a file named "pubspec.yaml" in "H:\Flutter\.pub-cache\hosted\pub.dartlang.org\vm_service-7.3.0" Flutter 调试 /root/.pub-cache/hosted/pub.dartlang.org 包中的编译错误 - Flutter debug compilation error from /root/.pub-cache/hosted/pub.dartlang.org packages 尝试在 https://pub.dartlang.org 查找 package cupertino_icons 时出现套接字错误 - Got socket error trying to find package cupertino_icons at https://pub.dartlang.org 尝试在 https://pub.dartlang.org 上查找包 english_words 时出现套接字错误 - Got socket error trying to find package english_words at https://pub.dartlang.org 尝试在 https://pub.dartlang.org 上查找包 ABC 时出现 TLS 错误 - Got TLS error trying to find package ABC at https://pub.dartlang.org
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM