Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter firebase-admob check if rewarded video is loading

Using flutter and this plugin (https://pub.dartlang.org/packages/firebase_admob),

How can I check if the Rewarded video is load?

I received this Exception :

PlatformException(ad_not_loaded, show failed for rewarded video, no ad was loaded, null)

but i can't capture it.

Thank you.

like image 338
John Avatar asked Jan 27 '23 20:01

John


1 Answers

You need to use the await keyword

 void showRewardedAd() async {
    try {
      await RewardedVideoAd.instance.load(
          adUnitId: RewardedVideoAd.testAdUnitId, targetingInfo: targetingInfo);

      await RewardedVideoAd.instance.show();
    } on PlatformException catch (e) {
      print(e.message);
    }
  }

and on your listener method add below lines

 if (event == RewardedVideoAdEvent.loaded) {
        setState(() {
         isRewardADLoaded = true;
        });
      }
like image 141
New Dev Avatar answered Feb 13 '23 05:02

New Dev