Reputation: 205
I'm using Rate My App package for playstore rating. All setup well from Installation to Implementation, but when I'm running the App, It show me an error and the build fails.
This is the Error I'm getting
/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)
I've tried many solutions such as flutter clean
flutter pub upgrade
and also some changes to the AndroidManifest.xml file, MainActivity.kt file as guided in the Upgrade to Android Embedding V2 for Android but none of these solution worked for me.
This issue is not present in Github as well Rate My App Issues
Also watched and done changes according to this tutorial as well, but still getting the same issue.
This is what my Material App Widget looks like
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,
);
},
);
Rate My App Widget
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!),
);
}
The error I'm getting is something from the package file named core.dart
Github link for core.dart
And lastly this is my pubspec.yaml dependency
rate_my_app: ^1.1.1+1
I also have Flutter Easy Loading pacakge installed for the loader. I've seen somewhere that easyloading may cause some issues. As I've implemented it on 80% of my project so I haven't removed it. Don't think that this package will cause something like this.
How can I solve this issue.
Upvotes: 3
Views: 4352
Reputation: 450
I'm not sure about the answer but what i got from the error codes is that:
Make sure you have the latest dart sdk and you are using naming the package like for example import 'package:rate_my_app/rate_my_app.dart' as rma; and edit the code where it shows errors.
the package is not installed properly.. by searching 'rate' in pubspec.lock file just above .yaml file and first remove rate my app dependencies from both lock and yaml and then reinstall then.
You have declared the ratemyapp object outside the stateful class and you are using it as this.ratemyapp.. you need to put it inside the stateful class and rename it to any other variable:
RateMyApp? rateMyApplication;
why because you are using similar variable below when you are setting the state oninitialzation method.
Lastly you can check if you have added this in main.dart
WidgetsFlutterBinding .ensureInitialized(); before runApp(MyApp());
Upvotes: 0
Reputation: 90135
You must add import 'dart:async';
to use unawaited
and must set the minimum Dart SDK version to 2.15.0 or higher.
For older Dart versions, you can get unawaited
from package:pedantic
instead.
Upvotes: 4