[英]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 类并为
onLongPressDragStart
、 onLongPressDragUpdate
和onLongPressDragUp
实现回调。 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.奇怪的是,其他回调(
onScaleStart
和onScaleUpdate
)不会抛出错误。
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.