How to Remove the Ads with the help of in-app purchase in flutter app

Viewed 1516

I want to Disabled Admob Ads After User Purchase the Package for Remove Ads with Help in-app Purchase. I want to Remove Interstitial Ads and Rewarded Ads, Below is the Code for Interstitial and Rewarded Ads:

  InterstitialAd myInterstitial = InterstitialAd(
    adUnitId: Platform.isIOS ? ios_ads : android_ads,
    listener: (MobileAdEvent event) {
      print("InterstitialAd event is $event");
    },
  );

  myInterstitial
    ..load()

    ..show(
      anchorType: AnchorType.bottom,
      anchorOffset: 0.0,

    );

Rewarded Ad

 RewardedVideoAd.instance.listener =
      (RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
    if (event == RewardedVideoAdEvent.rewarded) {

    }
  };
  RewardedVideoAd.instance.load(adUnitId: Platform.isIOS ? ios_ads : android_ads, 
  targetingInfo: targetingInfo).then((v){

    print("log "+v.toString());
    if(v){
      RewardedVideoAd.instance.show();

    }

  });
1 Answers

Have a boolean to keep track of whether payment is made to remove ads or not. If this boolean is set to true, then don't call the ads code.

if(!isPaymentDone){
  // code to show ads
}
Related