How can i add Admob's ads to Flutter widgets tree?

268 views Asked by At

I am a new app developer planning to build a social media app. I want to run ads in that app but admob's ads are pretty annoying as they seem and I don't want to disappoint my users so I was thinking is there any way so that I can use my admob's ads in my widget tree and shape that add as per need like curving the edges displaying them inside a frame with scrolling feature enabled in flutter. I want to blend my ads with my ui/ux layout. If someone knows how can I do that please help me out. Thank You.

2

There are 2 answers

0
Omar Essam El-Din On

In my way , you can make Ad method to call it and give it sizes depends on your percentage for your screen like adBanner at bottom 15% of the screen

     void bannerAD (String id , BuildContext ctx ){

    BannerAd myBanner = BannerAd(
      adUnitId: id,
      size: AdSize.smartBanner,
    );

    myBanner
       ..load()
      ..show(
         anchorOffset: MediaQuery.of(ctx).size.height * 0.10,
        anchorType: AnchorType.top,
      );
  }
0
Deepak Lohmod On

You can use this plugin to merge ads in your layout. For example, if you want to show the ads in a list just like instagram then just wrap this inside any list.

AdmobBanner(
                      adUnitId: "yourAdUnitId",
                      adSize: AdmobBannerSize.MEDIUM_RECTANGLE,
                  ),

AdmobBanner is a widget which you can use anyware in your code.