Hi Jonathan,
Thank you for contacting the Mobile Ads SDK Support team.
You can close a Rewarded Ad after a user has earned a reward, you can use the following code:
rewardedAd.onUserEarnedReward.listen((reward) {
// Close the ad.
rewardedAd.dispose();
});
The rewardedAd.show() method will show the Rewarded Ad. The rewardedAd.onUserEarnedReward event will be fired when the user earns a reward. The reward object will contain information about the reward that the user has earned. The rewardedAd.dispose() method will close the Rewarded Ad.
Here is an example of how to use this code:
import 'package:google_mobile_ads/google_mobile_ads.dart';
void main() {
// Initialize the Mobile Ads SDK.
MobileAds.initialize();
// Create a RewardedAd object.
RewardedAd rewardedAd = RewardedAd(
adUnitId: 'ca-app-pub-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
);
// Load the RewardedAd.
rewardedAd.loadAd();
// Listen for the RewardedAd event.
rewardedAd.onUserEarnedReward.listen((reward) {
// Close the ad.
rewardedAd.dispose();
});
}
Kindly refer to the Rewarded implementation documentation for more details about it. Also, can you confirm whether the precache error exception is reproducible in our Google sample apps? If yes, kindly provide the below information to investigate and reproduce the precache error on our end.
![]() |
Mobile Ads SDK Team |