Search code examples
flutterdart-pub

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


I just created my first contribution to flutter. I can use my package just fine, but I get a very low score because of some errors found by dart analysis. I am using the GestureDetector class and implemented callbacks for onLongPressDragStart, onLongPressDragUpdate and 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) . My offending code can be found here on 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.

The dart package with the errors can be found here: https://pub.dartlang.org/packages/planner#-analysis-tab-.

So what could be causing this? And how do i fix it?


Solution

  • I had the same problem.

    The problem here is, that you've maybe used the latest features of 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 (e.g. newest features).

    For example edit your pubspec as follow:

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

    Best regards