gpt4 book ai didi

flutter - 错误 : The method 'unawaited' isn't defined for the class 'RateMyApp'

转载 作者:行者123 更新时间:2023-12-05 05:49:01 25 4
gpt4 key购买 nike

我正在使用 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 以及根据 Upgrade to Android Embedding V2 中的指导对 AndroidManifest.xml 文件、MainActivity.kt 文件进行了一些更改适用于 Android,但这些解决方案都不适合我。

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.dart Github link for core.dart

的包文件

最后这是我的 pubspec.yaml 依赖项

rate_my_app: ^1.1.1+1

我还为加载程序安装了 Flutter Easy Loading 包。我在某处看到 easyloading 可能会导致一些问题。因为我已经在我的项目的 80% 上实现了它,所以我没有删除它。不要认为这个包会导致这样的事情。

我该如何解决这个问题。

最佳答案

您必须添加 import 'dart:async'; 才能使用 unawaitedmust set the minimum Dart SDK version到 2.15.0 或更高版本。

对于较旧的 Dart 版本,您可以从 package:pedantic 获取 unawaited相反。

关于flutter - 错误 : The method 'unawaited' isn't defined for the class 'RateMyApp' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70732468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com