在flutter中打开链接之前显示InterstitialAd

问题描述

在执行 launchURL 之前加载我的广告。

buttonactionL: () async{
                await StartApp.showInterstitialAd();
                String url = "https://google.com";
                _launchURL(url);
              },

解决方法

调用showAds方法并在完成onAdClosedonAdFailedToLoad后执行launchURl操作:

  void showAds() {

    _interstitialAd = InterstitialAd(
      adUnitId: AdHelper.interstitialAdUnitId,request: AdRequest(),listener: AdListener(onAdLoaded: (ad) {
        print("Ad Loaded");
        showAds();
      },onAdClosed: (ad) {
        print("Closed Ad");
      },onAdOpened: (ad) {
        print("Opened Ad");
      },onAdFailedToLoad: (ad,error) {
        print("Failed to load Ad $error");
      }),);
    _interstitialAd.load();
  }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...