首页 > 解决方案 > Flutter 从 firebase_admob 切换到 google_mobile_ads

问题描述

我有一个Flutter移动应用程序(AndroidIOS)。我正在尝试从 firebase_admob 切换到google_mobile_ads

firebase_admob中,我曾经使用下面的构建器在底部显示横幅广告。无论用户导航到哪里,以下代码都会将横幅广告粘贴在我的应用程序底部。

    home: Dashboard(),
    builder: (context, widget) {
      return new Padding( 
              child: widget,
              padding: new EdgeInsets.only(bottom: paddingBottom),
            );
    },

切换到google_mobile_ads后,我相应地更改了代码并尝试将横幅粘贴在底部,但是当我转到其他屏幕时,广告消失了。firebase_admob之前没有发生这种情况。

    home: Dashboard(),
    builder: (context, widget) {
      if (!_loadingAnchoredBanner) {
        _loadingAnchoredBanner = true;
        _createAnchoredBanner(context);
      }
      return  (_anchoredBanner != null) ?
        Container(
          color: Colors.green,
          width: _anchoredBanner.size.width.toDouble(),
          height: _anchoredBanner.size.height.toDouble(),
          child: AdWidget(ad: _anchoredBanner),
        ): Container();
    },

现在,它根本不显示仪表板屏幕,而是在应用程序启动时仅在屏幕中央显示横幅广告。请帮忙。

在此处输入图像描述

标签: flutteradmobgooglemobileads

解决方案


推荐阅读