【发布时间】:2022-06-19 18:03:33
【问题描述】:
我正在使用 Rate My App 包进行 Playstore 评级。 从安装到实施的所有设置都很好,但是当我运行应用程序时,它显示错误并且构建失败。
这是我遇到的错误
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart:134:7: Error: The method 'unawaited' isn't defined for the class 'RateMyApp'.
- 'RateMyApp' is from 'package:rate_my_app/src/core.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'unawaited'.
unawaited(callEvent(RateMyAppEventType.iOSRequestReview));
^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart:154:5: Error: The method 'unawaited' isn't defined for the class 'RateMyApp'.
- 'RateMyApp' is from 'package:rate_my_app/src/core.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'unawaited'.
unawaited(callEvent(RateMyAppEventType.dialogOpen));
^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart:198:7: Error: The method 'unawaited' isn't defined for the class 'RateMyApp'.
- 'RateMyApp' is from 'package:rate_my_app/src/core.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'unawaited'.
unawaited(callEvent(RateMyAppEventType.iOSRequestReview));
^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart:204:5: Error: The method 'unawaited' isn't defined for the class 'RateMyApp'.
- 'RateMyApp' is from 'package:rate_my_app/src/core.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/rate_my_app-1.1.1+1/lib/src/core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'unawaited'.
unawaited(callEvent(RateMyAppEventType.starDialogOpen));
^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 29s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
我已经尝试了许多解决方案,例如flutter clean flutter pub upgrade 以及对 AndroidManifest.xml 文件、MainActivity.kt 文件的一些更改,如 Android 的Upgrade to Android Embedding V2 中的指导,但这些解决方案都不适合我。
Github 中也不存在此问题 Rate My App Issues
还根据this tutorial 观察并完成了更改,但仍然遇到同样的问题。
这就是我的 Material App Widget 的样子
RateAppInitWidget(
builder: (rateMyApp) {
return MaterialApp(
title: 'Etsal Card',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: initScreen == 0
? OnboardingScreen()
: MyHomePage(
rateMyApp: rateMyApp,
title: "Etsal Card",
),
builder: EasyLoading.init(),
debugShowCheckedModeBanner: false,
);
},
);
评价我的应用小部件
RateMyApp? rateMyApp;
static const playStoreId = 'com.example.etsalcard';
static const appstoreId = 'com.apple.mobilesafari';
@override
Widget build(BuildContext context) => RateMyAppBuilder(
rateMyApp: RateMyApp(
googlePlayIdentifier: playStoreId,
appStoreIdentifier: appstoreId,
minDays: 0,
minLaunches: 2,
remindDays: 7,
remindLaunches: 10,
),
onInitialized: (context, rateMyApp) {
setState(() => this.rateMyApp = rateMyApp);
if (rateMyApp.shouldOpenDialog) {
rateMyApp.showRateDialog(context);
}
},
builder: (context) => rateMyApp == null
? Center(child: CircularProgressIndicator())
: widget.builder(rateMyApp!),
);
}
我得到的错误来自名为core.dartGithub link for core.dart的包文件
最后这是我的 pubspec.yaml 依赖项
rate_my_app: ^1.1.1+1
我还为加载程序安装了Flutter Easy Loading pacakge。我在某处看到易加载可能会导致一些问题。因为我已经在 80% 的项目中实现了它,所以我没有删除它。不要以为这个包会导致这样的事情。
我该如何解决这个问题。
【问题讨论】:
标签: flutter