How to Show rewarded Video in flutter when a user clicks a flat button

Issue

I am new to Flutter and I need help in showing rewarded ads in my flutter app.
The app is used to load my website, my idea is to show rewarded videos when the user clicks a flat button and when the video is over or closed I need to get them to my website which is loaded in the background.
For showing the website I use web view plugin.

Solution

In your initstate just load the rewarded ad,

// load the rewarded video ad
   RewardedVideoAd.instance
    .load(
    adUnitId: RewardedVideoAd.testAdUnitId,
    targetingInfo: targetingInfo);

// listen for the rewarded add events
RewardedVideoAd.instance.listener =
    (RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
  print("Rewarded Video Ad event $event");
  if (event == RewardedVideoAdEvent.rewarded) {
    // here, you can load your website using your webview plugin
  }
};

Inside your onPressed() method, just show Rewarded Video Ad by using,

onPressed: () {
                RewardedVideoAd.instance.show();
              },

You’re done.

Answered By – Jay Mungara

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *