错误:没有名为“ onRatingChanged”的命名参数

时间:2020-05-14 18:30:25

标签: flutter rating dart-pub

我尝试运行该应用程序,但收到以下错误消息:

Compiler message:
../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-0.6.0+2/lib/src/dialogs.dart:272:17: Error: No named parameter with the name 'onRatingChanged'.
                onRatingChanged: (rating) {
                ^^^^^^^^^^^^^^^
../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/smooth_star_rating-1.1.0+1/lib/smooth_star_rating.dart:23:3: Context: Found this candidate, but the arguments don't match.
  SmoothStarRating({
  ^^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/ahmed/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/ahmed/Developer/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

有什么解决方法吗?

2 个答案:

答案 0 :(得分:6)

rate_my_app中将0.6.0+3的版本更新为pubspec.yaml

enter image description here

答案 1 :(得分:0)

使用actionsBuilder代替onRatingChanged。在最新的软件包中已将其替换。

_rateMyApp.init().then((_) {
  if (_rateMyApp.shouldOpenDialog) {
    _rateMyApp.showStarRateDialog(
      context,
      actionsBuilder: (context, stars) {
        return [
          FlatButton(
            onPressed: () {
              if (stars != null) {
                _rateMyApp.save().then((v) => Navigator.pop(context));

                if (stars <= 3) {
                  print("User Selected $stars");
                } else if (stars <= 5) {
                  print('Leave a Review Dialog');
                }
              } else {
                Navigator.pop(context);
              }
            },
            child: Text('OK'),
          )
        ];
      },
      title: "Have you made someone happy today?",
      message: "Please, review our app with 5 starts and make us happy",
      dialogStyle: DialogStyle(
          titleAlign: TextAlign.center,
          messageAlign: TextAlign.center,
          messagePadding: EdgeInsets.only(bottom: 20.0)),
      starRatingOptions: StarRatingOptions(),
    );
  }
});

}