【问题标题】:Rate my app package for Flutter not working评价我的 Flutter 应用程序包不工作
【发布时间】:2023-04-01 10:28:01
【问题描述】:

我正在尝试将 rate_my_app 包与我的颤振应用程序集成。我已经尝试了所有版本并出现同样的问题:找不到参数 onRatingChanged。我需要创建一个弹出评级对话框,我不介意使用任何其他包或类或修复这个,我也得到这个错误之后使用 rate_my_app 提供的代码

以下 NoSuchMethodError 被抛出附加到渲染树: I/flutter (13365):在 null 上调用了 getter 'millisecondsSinceEpoch'。 I/颤振(13365):接收器:空 I/flutter (13365):尝试调用:millisecondsSinceEpoch

我在 main.dart 中的代码

 RateMyApp rateMyApp = RateMyApp(
preferencesPrefix: 'rateMyApp_',
minDays: 1,
minLaunches: 1,


);



 @override
  void initState() {
    super.initState();
    if(rateMyApp.shouldOpenDialog){
      rateMyApp.showRateDialog(context,title: 'hii', message: 'please like');
    }

【问题讨论】:

标签: flutter dart


【解决方案1】:

this thread 中所述,尝试将smooth_star_rating 依赖项的版本修复为严格等于1.0.4+2。或者改成^1.1.0

【讨论】:

    【解决方案2】:

    请使用 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(),
        );
      }
    });
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多