Flutter Ad not filling the area

138 views
Skip to first unread message

pat

unread,
Sep 20, 2023, 7:51:27 AM9/20/23
to Google Mobile Ads SDK Developers

I am using   google_mobile_ads: ^3.0.0 on flutter.

Please see the attached image. The issue is ad does not fill up the entire area. It looks odd. Is there a plan to fix this issue anytime soon?

My code below.

class AdBanner extends StatefulWidget {
  const AdBanner({Key? key}) : super(key: key);

  @override
  State<AdBanner> createState() => _AdBannerState();
}

class _AdBannerState extends State<AdBanner> {
  BannerAd? _inlineAdaptiveAd;
  bool _isLoaded = false;

  @override
  void initState() {
    super.initState();
    _loadAd();
  }

  void _loadAd() async {
    await _inlineAdaptiveAd?.dispose();
    // Get an inline adaptive size for the current orientation.
    AdSize size = AdSize.banner;
    //if (width >= 468) size = AdSize.fullBanner;
    //if (width >= 728) size = AdSize.leaderboard;

    _inlineAdaptiveAd = BannerAd(
      adUnitId: AdHelper.bannerAdUnitId,
      size: size,
      request: const AdRequest(),
      listener: BannerAdListener(
        onAdLoaded: (Ad ad) async {
          debugPrint('Inline adaptive banner loaded: ${ad.responseInfo}');

          // After the ad is loaded, get the platform ad size and use it to
          // update the height of the container. This is necessary because the
          // height can change after the ad is loaded.
          //BannerAd bannerAd = (ad as BannerAd);
          // _finalSize = await bannerAd.getPlatformAdSize();
          // if (size == null) {
          //   debugPrint(
          //       'Error: getPlatformAdSize() returned null for $bannerAd');
          //   return;
          // }

          if (mounted) {
            setState(() {
              //_inlineAdaptiveAd = bannerAd;
              _isLoaded = true;
            });
          }
        },
        onAdFailedToLoad: (Ad ad, LoadAdError error) {
          debugPrint('Inline adaptive banner failedToLoad: $error');
          _isLoaded = false;
          ad.dispose();
        },
      ),
    );
    await _inlineAdaptiveAd!.load();
  }

  @override
  Widget build(BuildContext context) {
    return (_isLoaded && _inlineAdaptiveAd != null)
        ? Align(
            alignment: Alignment.bottomCenter,
            child: SizedBox(
                width: _inlineAdaptiveAd!.size.width.toDouble(),
                height: _inlineAdaptiveAd!.size.height.toDouble(),
                child: AdWidget(
                  ad: _inlineAdaptiveAd!,
                )))
        : const SizedBox(
            width: 0,
            height: 0,
          );
  }

  @override
  void dispose() {
    _inlineAdaptiveAd?.dispose();

    super.dispose();
  }
}
Untitled.png

Mobile Ads SDK Forum Advisor

unread,
Sep 21, 2023, 3:20:27 AM9/21/23
to tnppres...@gmail.com, google-adm...@googlegroups.com
Hi, 

Thank you for contacting the Mobile Ads SDK support team.

By reviewing your concern, I understand that you want to fill up the entire area in the Ad. For achieving the full width banner kindly update the size with the below details

AdSize size = (await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
        MediaQuery.of(context).size.width.truncate())) as AdSize;

If you have any more queries, please feel free to get back to us.

 
This message is in relation to case "ref:_00D1U1174p._5004Q2ozlo6:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


اذاعةالريماس الفضائية

unread,
Sep 21, 2023, 3:48:06 AM9/21/23
to Mobile Ads SDK Forum Advisor, tnppres...@gmail.com, google-adm...@googlegroups.com
اني بحاجة الى ترتيب التطبيق انا اواجة بعض الاخطاء ولم افهم الامور الكاملة ولاكن افهم جزء الامور الاعلاني

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/fO6H6000000000000000000000000000000000000000000000S1BR1900svO_4ObXSn6qcXg_-FfpgA%40sfdc.net.

M Bashir Babar

unread,
Sep 21, 2023, 9:45:34 AM9/21/23
to '0'9)'D1JE'3 'DA6'&J), tnppres...@gmail.com, google-adm...@googlegroups.com, Mobile Ads SDK Forum Advisor
Thanks for the detailed instructions. I have tried updating the size as suggested, but I am still facing some issues. Could you please provide me with some more information on how to fix this?

Mobile Ads SDK Forum Advisor

unread,
Sep 22, 2023, 2:38:46 AM9/22/23
to mbashi...@gmail.com, karars...@gmail.com, google-adm...@googlegroups.com, tnppres...@gmail.com
Hi, 

Thank you for getting back to us.

Could you please let us know what issues you are facing while updating the size?

Tharindu Patikirikorala

unread,
Sep 22, 2023, 2:49:25 AM9/22/23
to Mobile Ads SDK Forum Advisor, mbashi...@gmail.com, karars...@gmail.com, google-adm...@googlegroups.com
image.png
The code you provided above cut off certain ads from the bottom and right. See the above screenshot.

This is the code. You can see the full code in my previous email.
AdSize size = (await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
        MediaQuery.of(context).size.width.truncate())) as AdSize;

Mobile Ads SDK Forum Advisor

unread,
Sep 26, 2023, 2:28:33 AM9/26/23
to tnppres...@gmail.com, mbashi...@gmail.com, karars...@gmail.com, google-adm...@googlegroups.com
Hi, 

Thank you for getting back to us.

By reviewing your concern, I understand that your ads are getting cropped. Mobile Ads SDK is responsible only for requesting Ad from the server and does not have any control on the ad it receives.

Your concern is more related to the product rather than Mobile Ads SDK implementation. I would recommend reaching out to the Product Support Team as they are better equipped to address your concern.
Reply all
Reply to author
Forward
0 new messages